Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.

Commit 7040fdb

Browse files
author
wimo7
committed
Updated path to logging config file.
1 parent 23f4a20 commit 7040fdb

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

utils/log_manager.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
import logging.config
33
import os
44

5+
logger = logging.getLogger(__name__)
6+
new_event_logger = logging.getLogger(f'{__name__}.new_member')
7+
58

69
# https://fangpenlin.com/posts/2012/08/26/good-logging-practice-in-python/
7-
def setup_logging(
8-
default_path='log_config.json',
9-
default_level=logging.INFO,
10-
env_key='LOG_CFG'
11-
):
12-
path = default_path
13-
value = os.getenv(env_key, None)
14-
if value:
15-
path = value
16-
if os.path.exists(path):
17-
with open(path, 'rt') as f:
10+
def setup_logging(default_path='log_config.json',
11+
default_level=logging.INFO
12+
):
13+
file_path = os.path.join(os.path.dirname(__file__), default_path)
14+
15+
if os.path.exists(file_path):
16+
with open(file_path, 'rt') as f:
1817
config = json.load(f)
1918
logging.config.dictConfig(config)
19+
2020
else:
2121
logging.basicConfig(level=default_level)
22+
logger.warning('Warning, verify there is no desired config file')

0 commit comments

Comments
 (0)