File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 21
21
import os
22
22
import sys
23
23
24
+ import application .paths
24
25
import yaml
25
26
from flask import Flask , Blueprint , jsonify
26
27
from werkzeug .exceptions import HTTPException
27
28
from werkzeug .serving import WSGIRequestHandler
28
29
29
- logger = logging .getLogger (__name__ )
30
-
31
30
try :
32
31
with open ('log_config.yaml' ) as config_file :
33
32
config = yaml .safe_load (config_file .read ())
34
33
35
- os .makedirs (os .path .join (os .getcwd (), 'logs' ), exist_ok = True )
34
+ config ['handlers' ]['timedRotatingFile' ]['filename' ] = paths .LOG_FILE_PATH
35
+ paths .makedir_if_not_exists (paths .LOGS_DIR_PATH )
36
36
logging .config .dictConfig (config )
37
37
except Exception :
38
38
# Fallback to a basic configuration
39
39
logging .basicConfig (format = '%(asctime)s %(levelname)s [%(name)s:%(lineno)d] %(message)s' , level = logging .INFO , force = True )
40
+
41
+ logger = logging .getLogger (__name__ )
40
42
logger .exception ("Logging setup failed" )
41
43
else :
44
+ logger = logging .getLogger (__name__ )
42
45
logger .warning ("Logging setup is completed with config=%s" , config )
43
46
44
47
from .Profile .Profile import Profile
Original file line number Diff line number Diff line change @@ -39,3 +39,5 @@ def makedir_if_not_exists(path):
39
39
USER_PROFILE_PATH = os .path .join (PROFILE_PATH , "user_profile.json" )
40
40
PRIVATE_KEY_PATH = os .path .join (PROFILE_PATH , "private_keys" )
41
41
makedir_if_not_exists (PRIVATE_KEY_PATH )
42
+ LOGS_DIR_PATH = os .path .join (PROFILE_PATH , 'logs' )
43
+ LOG_FILE_PATH = os .path .join (LOGS_DIR_PATH , 'ictrl_log.log' )
Original file line number Diff line number Diff line change 1
1
version : 1
2
- disable_existing_loggers : False
2
+ disable_existing_loggers : True
3
3
4
4
formatters :
5
5
default :
@@ -12,15 +12,15 @@ handlers:
12
12
level : DEBUG
13
13
formatter : default
14
14
stream : ext://sys.stderr
15
- file_rotating :
15
+ timedRotatingFile :
16
16
class : logging.handlers.TimedRotatingFileHandler
17
17
level : DEBUG
18
- filename : logs/ictrl_log.log
19
18
formatter : default
20
- when : ' midnight'
21
- interval : 1
22
- backupCount : 14
19
+ when : H
20
+ interval : 3
21
+ backupCount : 112
22
+ # filename: dynamically assigned upon the initialization of the program
23
23
24
24
root :
25
25
level : DEBUG
26
- handlers : [console, file_rotating ]
26
+ handlers : [console, timedRotatingFile ]
You can’t perform that action at this time.
0 commit comments