improve logging setup

This commit is contained in:
Maximilian Keßler 2023-05-14 14:04:42 +02:00
parent aafd1ca1ec
commit 357e98b8db
Signed by: max
GPG key ID: BCC5A619923C0BA5
2 changed files with 17 additions and 4 deletions

3
log_setup/__init__.py Normal file
View file

@ -0,0 +1,3 @@
from .logger_setup import make_logger
logger = make_logger()

View file

@ -1,10 +1,20 @@
import logging
logger = logging.getLogger("HANAB")
def make_logger():
logger = logging.getLogger("hanab-suite")
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler("log.txt")
f_handler = logging.FileHandler("a_log.txt")
f_formatter = logging.Formatter(
'[%(asctime)s] [%(name)s] [%(levelname)s]: %(message)s'
)
f_handler.setFormatter(f_formatter)
logger.addHandler(f_handler)
logger.addHandler(handler)
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
logger.addHandler(console_handler)
return logger