2022-04-23 21:00:22 +02:00
|
|
|
import logging
|
2022-04-24 15:34:03 +02:00
|
|
|
from logging.handlers import RotatingFileHandler
|
2022-04-23 21:00:22 +02:00
|
|
|
|
2022-04-24 15:34:03 +02:00
|
|
|
# log info level logs to stdout and debug to debug file
|
2022-04-23 21:00:22 +02:00
|
|
|
|
2022-04-24 15:34:03 +02:00
|
|
|
log_format = "%(levelname)s %(asctime)s - %(message)s"
|
|
|
|
logging.basicConfig(
|
2022-04-24 18:11:19 +02:00
|
|
|
handlers=[RotatingFileHandler('../config/debug.log', maxBytes=100000, backupCount=10)],
|
2022-04-24 15:34:03 +02:00
|
|
|
level=logging.DEBUG,
|
|
|
|
format=log_format)
|
2022-04-23 21:00:22 +02:00
|
|
|
|
2022-04-24 15:34:03 +02:00
|
|
|
stream = logging.StreamHandler()
|
|
|
|
stream.setLevel(logging.INFO)
|
|
|
|
stream_format = logging.Formatter(log_format)
|
|
|
|
stream.setFormatter(stream_format)
|
2022-04-23 21:00:22 +02:00
|
|
|
|
|
|
|
def get_logger(name):
|
2022-04-24 15:34:03 +02:00
|
|
|
l = logging.getLogger(name)
|
|
|
|
l.addHandler(stream)
|
|
|
|
return l
|