improve logging setup
This commit is contained in:
parent
aafd1ca1ec
commit
357e98b8db
2 changed files with 17 additions and 4 deletions
3
log_setup/__init__.py
Normal file
3
log_setup/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from .logger_setup import make_logger
|
||||||
|
|
||||||
|
logger = make_logger()
|
|
@ -1,10 +1,20 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("HANAB")
|
def make_logger():
|
||||||
|
logger = logging.getLogger("hanab-suite")
|
||||||
|
|
||||||
logger.setLevel(logging.DEBUG)
|
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
|
||||||
|
|
Loading…
Reference in a new issue