Refactor logging configuration
parent
e50fadb35c
commit
a94fdd2dfb
@ -0,0 +1,17 @@
|
|||||||
|
import logging.config
|
||||||
|
import os
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def setup_logging(path="./src/logging.yaml", default_level=logging.INFO):
|
||||||
|
"""
|
||||||
|
Setup logging configuration
|
||||||
|
"""
|
||||||
|
if os.path.exists(path):
|
||||||
|
with open(path, "rt") as f:
|
||||||
|
config = yaml.safe_load(f.read())
|
||||||
|
logging.config.dictConfig(config)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(level=default_level)
|
||||||
|
return logging.getLogger(__name__)
|
Loading…
Reference in New Issue