forked from topel/emoMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
31 lines (24 loc) · 877 Bytes
/
settings.py
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
30
31
__author__ = 'thomas'
import logging
def init(log_file_name, withFile):
global logger
logger = logging.getLogger(__name__)
# logger = logging.getLogger(__name__)
# logging.basicConfig(level=logging.INFO,filename='example.log')
log_level=logging.INFO
logger.setLevel(log_level)
# create console handler
ch = logging.StreamHandler()
ch.setLevel(log_level)
# create formatter and add it to the handlers
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger.addHandler(ch)
ch.setFormatter(formatter)
if withFile:
# create file handler which logs even debug messages
fh = logging.FileHandler(log_file_name)
fh.setLevel(log_level)
fh.setFormatter(formatter)
# add the handlers to the logger
logger.addHandler(fh)
# return logger