-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.py
92 lines (76 loc) · 3.25 KB
/
common.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
# coding=utf-8
import logging
import os
from collections import OrderedDict
roomNameDict = OrderedDict([
('sc2rain', '大雨神'),
('egjd', '菜东'),
('khansolar', "Samsung's Zerg Solar"),
('sc2creator', 'sc2creator'),
('bostossmc', '神族总统MC'),
('krfantasy', '范太子'),
('polt', '高富帅 polt'),
('naniwasc2', 'naniwa'),
('axryung', 'Ryung LoTV'),
('liquidsnute', '挪威虫族snute'),
('forgg', 'forgg'),
('dirtyela_tv', '德国妹子 DirtyEla'),
('gayoung_kim', '韩国妹子 Aphrodite'),
('missmagitek', '星际妹子 missmagitek'),
('livibee', '星际妹子 livibee'),
('inksie', '星际妹子 inksie'),
('Journey92', 'SAMSUNG Journey'),
('mYiSacsri', 'mYiSacsri'),
('liquidmana', 'liquidMaNa '),
('mdstephano', 'Stephano LoTV'),
('liquidtlo', 'LiquidTLO 欧服'),
('firecake', '莽夫-火蛋糕'),
('wayne379', '台湾谐星-鬼手辉'),
('totalbiscuit', '咆哮杯~'),
('redbullesports', '红牛杯-执政官-LoTV'),
('starcraft', 'startcraft'),
])
watchlist = list(map(lambda x: x[0], roomNameDict.items()))
# print(roomNameDict['egjd'])
# print(watchlist)
# watchlist = ['sc2rain', 'egjd','krfantasy','sc2creator','khansolar','axryung','Journey92','forgg', 'bostossmc', 'mdstephano','naniwasc2','liquidmana', 'inksie', 'missmagitek', 'livibee','redbullesports', 'wayne379']
def config_log(log_dir, log_file, log_level='INFO',
back_count=7, name="", enable_stream_handler=True,
multithreading=False, multiprocessing=False):
log_file = os.path.join(log_dir, log_file)
log_format = '[%(levelname)s]'
if multithreading:
log_format += '<t%(thread)d - %(threadName)s>'
if multiprocessing:
log_format += '<p%(process)d - %(processName)s>'
log_format += '<%(module)s>-%(funcName)s: %(message)s --- %(asctime)s'
log_formatter = logging.Formatter(log_format)
loghandler_file_rotated = logging.handlers.TimedRotatingFileHandler(
log_file, when='midnight', interval=1, backupCount=back_count)
loghandler_file_rotated.setFormatter(log_formatter)
loghandler_file_rotated.setLevel(getattr(logging, log_level.upper(), None))
if enable_stream_handler:
loghandler_stream = logging.StreamHandler()
loghandler_stream.setFormatter(log_formatter)
loghandler_stream.setLevel(logging.DEBUG)
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
logger.addHandler(loghandler_file_rotated)
if enable_stream_handler:
logger.addHandler(loghandler_stream)
def only_stream(name, log_level='INFO', multithreading=False,
multiprocessing=False):
log_format = '[%(levelname)s]'
if multithreading:
log_format += '<t%(thread)d - %(threadName)s>'
if multiprocessing:
log_format += '<p%(process)d - %(processName)s>'
log_format += '<%(module)s>-%(funcName)s: %(message)s --- %(asctime)s'
log_formatter = logging.Formatter(log_format)
loghandler_stream = logging.StreamHandler()
loghandler_stream.setFormatter(log_formatter)
loghandler_stream.setLevel(logging.DEBUG)
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
logger.addHandler(loghandler_stream)