-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
35 lines (28 loc) · 997 Bytes
/
utils.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
32
33
34
import logging
import os
import sys
debug_maping = {
'error':logging.ERROR,
'info':logging.INFO,
'warning':logging.WARNING,
'debug':logging.DEBUG,
}
def init_logger():
logger = logging.getLogger()
formatter_str = '%(asctime)s [%(process)d:%(threadName)s] %(levelname)-8s[%(filename)s:%(lineno)d] %(message)s'
formatter = logging.Formatter(formatter_str, '%Y-%m-%d %H:%M:%S')
logger.setLevel(debug_maping.get("debug"))
# handler = logging.FileHandler(os.path.join(sys.path[0],'debug.log'))
handler = logging.FileHandler(os.path.join('/','log','debug.log'))
handler.setFormatter(formatter)
for item in logger.handlers:
item.close()
logger.removeHandler(item)
logger.addHandler(handler)
ch = logging.StreamHandler()
ch.setFormatter(formatter)
ch.setLevel(debug_maping.get("debug"))
logger.addHandler(ch)
def set_data(server, client, fields):
for field in fields:
client[field] = server[field]