def setup_logging(self, default_path=PATH_LOGGING, default_level=logging.INFO, env_key='LOG_CFG'):
path = default_path
self.logconf = None
value = os.getenv(env_key, None)
if value:
path = value
if os.path.exists(path):
with open(path, 'rt') as f:
config = json.load(f)
self.logconf = logging.config.dictConfig(config)
elif os.path.exists(path.replace("../", "")):
with open(path.replace("../", ""), 'rt') as f:
config = json.load(f)
self._changePath(config["handlers"])
self.logconf = logging.config.dictConfig(config)
else:
print("Configurazione log non trovata (\"%s\"): applico le impostazioni predefinite" % path)
self.logconf = logging.basicConfig(level=default_level)
评论列表
文章目录