-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloggerUtil.py
More file actions
29 lines (21 loc) · 784 Bytes
/
loggerUtil.py
File metadata and controls
29 lines (21 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import configparser
import logging
config = configparser.ConfigParser()
config.read('logger.config')
def getLogLevel(configLogLevel):
if(configLogLevel == 'DEBUG'):
return logging.DEBUG
elif(configLogLevel == 'INFO'):
return logging.INFO
elif(configLogLevel == 'WARNING'):
return logging.WARNING
elif(configLogLevel == 'ERROR'):
return logging.ERROR
else:
return logging.CRITICAL
def getLogger():
logging.basicConfig(filename=config['DEFAULT']['Filename'],
format='[%(asctime)s] [%(levelname)s] [%(message)s]',
filemode=config['DEFAULT']['Filemode'],
level=getLogLevel(config['DEFAULT']['LogLevel']))
return logging.getLogger()