picologging
picologging copied to clipboard
Using `asctime` in formatter messes up timestamp encoding
Using the example below, picologging produces messy encoding for timestamps, e.g.:
INFO - �i�j,-1224597123 - root - <unknown> - A log message!
WARNING - HE��,-1224597123 - root - <unknown> - A log message with arguments
Using the standard library the same code produces the expected result:
INFO - 2024-02-17 13:14:50,850 - root - logging_demo - A log message!
WARNING - 2024-02-17 13:14:50,850 - root - logging_demo - A log message with arguments
This has been tested with picologging 0.9.3 on Ubuntu 22.04 with Python 3.10.12 and with picologging 0.9.6 on Win10 with Python 3.11.7. This also happens for lower versions (0.8.x, 0.7.x, 0.6.x) but with less intensity, e.g.:
LINUX:
INFO - 2024-02-17 13:23:59,-1224344203 - root - <unknown> - A log message!
WARNING - 2024-02-17 13:23:59,-1224344203 - root - <unknown> - A log message with arguments
WINDOWS:
INFO - ,-1224369277 - root - <unknown> - A log message!
WARNING - ,-1224369276 - root - <unknown> - A log message with arguments
Example:
import picologging as logging
# import logging
logging.basicConfig(format="%(levelname)s - %(asctime)s - %(name)s - %(module)s - %(message)s")
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.info("A log message!")
logger.warning("A log message with %s", "arguments")
if __name__ == '__main__':
pass