steamgifts-bot/src/log.py
mcinj 4b8a9fe7b7 Store the debug log file in the config folder.
- Storing in the config folder allows easy access when running via docker.
 - Small log output change
2022-04-24 12:11:19 -04:00

20 lines
588 B
Python

import logging
from logging.handlers import RotatingFileHandler
# log info level logs to stdout and debug to debug file
log_format = "%(levelname)s %(asctime)s - %(message)s"
logging.basicConfig(
handlers=[RotatingFileHandler('../config/debug.log', maxBytes=100000, backupCount=10)],
level=logging.DEBUG,
format=log_format)
stream = logging.StreamHandler()
stream.setLevel(logging.INFO)
stream_format = logging.Formatter(log_format)
stream.setFormatter(stream_format)
def get_logger(name):
l = logging.getLogger(name)
l.addHandler(stream)
return l