File tree 2 files changed +11
-12
lines changed
2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import logging
3
3
import logging .config
4
- import json
5
4
6
5
__name__ = "pytextdist"
7
6
__version__ = "0.1.5"
19
18
20
19
"""
21
20
Set up logging
22
- | Default logging configuration can be edited in logging.json.
21
+ | Default logging configuration can be edited in logging.yaml
23
22
| You can also bring customized logging modules.
24
23
"""
25
24
26
25
env_key = "LOG_CFG"
27
26
value = os .getenv (env_key , None )
28
27
29
28
init_file_dir = os .path .dirname (os .path .abspath (__file__ ))
30
- logger_config_json_path = value if value else os .path .join (init_file_dir , "logging.json " )
29
+ logger_config_yaml_path = value if value else os .path .join (init_file_dir , "logging.yaml " )
31
30
logger_default_level = logging .INFO
32
31
33
- if os .path .exists (logger_config_json_path ):
34
- with open (logger_config_json_path , "rb" ) as f :
35
- try :
36
- config = json .load (f )
37
- except :
38
- config = json .loads (f .read ().decode ('utf-8' ))
39
- logging .config .dictConfig (config )
40
- else :
32
+ try :
33
+ import yaml
34
+ if os .path .exists (logger_config_yaml_path ):
35
+ with open (logger_config_yaml_path , "rt" ) as f :
36
+ config = yaml .safe_load (f .read ())
37
+ logging .config .dictConfig (config )
38
+ else :
39
+ logging .basicConfig (level = logger_default_level )
40
+ except :
41
41
logging .basicConfig (level = logger_default_level )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments