diff options
Diffstat (limited to 'labbot/logger.py')
-rw-r--r-- | labbot/logger.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/labbot/logger.py b/labbot/logger.py new file mode 100644 index 0000000..067bcac --- /dev/null +++ b/labbot/logger.py @@ -0,0 +1,19 @@ +import sys +import logging + +def init(level: int): + logger = logging.getLogger() + logger.setLevel(level) + + formatter = logging.Formatter( + "[{asctime}] [{levelname}] {name}: {message}", datefmt="%Y-%m-%d %H:%M:%S", style="{" + ) + + if not sys.stdout.closed: + stdout_handler = logging.StreamHandler(sys.stdout) + stdout_handler.setFormatter(formatter) + + logger.addHandler(stdout_handler) + + + logging.captureWarnings(True)
\ No newline at end of file |