Py-Hanabi/log_setup/logger_setup.py

21 lines
496 B
Python
Raw Normal View History

2023-03-15 15:42:22 +01:00
import logging
2023-05-14 14:04:42 +02:00
def make_logger():
logger = logging.getLogger("hanab-suite")
2023-03-15 15:42:22 +01:00
2023-05-14 14:04:42 +02:00
logger.setLevel(logging.DEBUG)
2023-03-15 15:42:22 +01:00
2023-05-14 14:04:42 +02:00
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)
2023-03-15 15:42:22 +01:00
2023-05-14 14:04:42 +02:00
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)
logger.addHandler(console_handler)
return logger