Releases: Dragon2fly/logger_tt
Stable version v1.7.4
-
Fixed:
- TelegramHandler re-grouped an already grouped message. Now messages are correctly grouped once.
- Handlers from all loggers other than the root were mistakenly added to the root's handlers.
This bug prevents the removal of handlers out of the root, thus the log message was doubled if another different handler was used. Now root's handlers are correctly added or removed (thank ZeroRin).
-
Usability:
- Multiprocessing:
- Changed the method of detecting child process, potentially fixing all issues related to multiprocessing and pyinstaller
- logger's server port now automatically picks up a random available port instead of
DEFAULT_TCP_LOGGING_PORT
. This means in the case of running many multiprocessing applications at the same time, the user doesn't need to care about theport
parameter anymore. Each application will pick its port, and its child processes will connect to the correct port, and thus log to the correct destination. - Added
server_timeout
argument tosetup_logging()
: allow the user to control how long should the log listener server
wait before exiting following the death of the main thread. - Added
client_only
argument tosetup_logging()
: enable different independent applications to log to the same destination.
- TelegramHandler: If the message is longer than 3072 characters, it will be split into parts and sent one by one.
This is to avoid reaching the Telegram API's limit of 4096 characters per message, which users should rarely reach. - Format styles: added support for
{
(string.format) and$
(string.Template) formats. The same style could be used acrossfomatter
's format and log message's format.
- Multiprocessing:
Stable version v1.7.3
- Usability:
- Not to import custom handlers (StreamHandlerWithBuffer, TelegramHandler, etc) if they are not used in any logger.
- TelegramHandler:
- Better network error handling.
- Added
grouping_interval
to group many log messages that are within the samex
seconds interval into one before sending.
This reduces the number of times it sends messages to the Telegram server and helps to avoid Http-429 error.
Stable version v1.7.1
- Fixed: exception raised while handling another exception is now shown correctly (thank ZeroRin).
- New functionality:
- Added
TelegramHandler
. Now you can send logs directly to telegram users/groups. - Support Python 3.11
Fine-grained error locations
in tracebacks.
- Added
- Usability:
- Added level NOTICE = INFO + 5. You can do
logger.notice("your message")
. - Add set/remove
context injector
methods.
You can add additional information to the log record before it is actually handled.
Refer to theTelegramHandler
for a usage sample. - You can now set different log paths for different handlers by passing a dict to
setup_logging
(thank ZeroRin).
- Added level NOTICE = INFO + 5. You can do
Stable version v1.7.0
-
Fixed:
- multiprocessing: logfile rollover fails as the child process keeps opening the file.
- multiprocessing: if the log path is set by a variable with time,
the child process creates a new redundant log path.
-
New functionality: Added
StreamHandlerWithBuffer
. Buffer the log output by time or by line number.
GUI app could use this handler to keep the app responsive while having a tremendous log output. -
Usability: In multiprocessing logging,
users can set the log server address themselves throughsetup_logging
or log config file.
Stable version v1.6.1
-
Added
limit_line_length
parameter:
log only maximumn
characters for each traceback line. This prevents dumping the whole huge content of the variable into the log.n=1000
by default. -
Added
analyze_raise_statement
parameter:
logger-tt no longer analyzes the raise statement by default. This avoids logging value of variables on the raise statement two time, especially when the content of these variables are huge.
Stable version v1.6.0
-
Exception on the multiline statement
From python 3.6 to 3.9, thetokenize
module and the exception traceback have changed their behavior. So if a multiline statement raised an exception, the lines reported were different between different python versions. Sometimes, too many unrelated lines were reported too.- This release tries to mitigate that and grabs all the lines of the multiline statement as correctly as possible.
- If there are too many lines, it limits the line to be shown to 10.
-
Logging uncaught exception in child thread
Child thread is run in atry-finally
by default, so it doesn't callsys.excepthook
when an uncaught exception occurred.
Sologger-tt
doesn't receive the traceback to log it.
This release replaces the thread defaulttry-finally
totry-except-finally
andlogger-tt
handles the uncaught exception normally.Python 3.8+ has a new
thread.excepthook
. But sincelogger-tt
has already handled the uncaught exception, thisthread.excepthook
won't be called.
Stable version v1.5.2
The default logger named logger_tt
can be imported in all modules by from logger_tt import logger
.
This logger acts like regular loggers from logger = logging.getLogger(__name__)
,
but smart enough to inject threadName
, processName
if present.
This enables us to use one logger everywhere. Thus the code is even simpler.