forked from p15670423/monkey
cc: reformat island_logger.py for readability
1. Adjusted some spacing and indentation 2. Reformatted with Black
This commit is contained in:
parent
fef44bcd05
commit
4cb28db3bc
|
@ -2,10 +2,12 @@ import json
|
|||
import logging.config
|
||||
import os
|
||||
|
||||
__author__ = 'Maor.Rayzin'
|
||||
__author__ = "Maor.Rayzin"
|
||||
|
||||
|
||||
def json_setup_logging(default_path='logging.json', default_level=logging.INFO, env_key='LOG_CFG'):
|
||||
def json_setup_logging(
|
||||
default_path="logging.json", default_level=logging.INFO, env_key="LOG_CFG"
|
||||
):
|
||||
"""
|
||||
Setup the logging configuration
|
||||
:param default_path: the default log configuration file path
|
||||
|
@ -15,11 +17,13 @@ def json_setup_logging(default_path='logging.json', default_level=logging.INFO,
|
|||
"""
|
||||
path = default_path
|
||||
value = os.getenv(env_key, None)
|
||||
|
||||
if value:
|
||||
path = value
|
||||
|
||||
if os.path.exists(path):
|
||||
with open(path, 'rt') as f:
|
||||
with open(path, "rt") as f:
|
||||
config = json.load(f)
|
||||
logging.config.dictConfig(config)
|
||||
logging.config.dictConfig(config)
|
||||
else:
|
||||
logging.basicConfig(level=default_level)
|
||||
|
|
Loading…
Reference in New Issue