-
Notifications
You must be signed in to change notification settings - Fork 7
/
log.py
34 lines (21 loc) · 932 Bytes
/
log.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
from settings import LOG_LEVEL, LOG_FILE, LOG_FORMAT
from logging import *
class Log(object):
def __init__(self):
self.logger = getLogger()
self.logger.setLevel(LOG_LEVEL)
log_formatter = Formatter(LOG_FORMAT, "%Y-%m-%d %H:%M:%S")
file_handler = FileHandler(LOG_FILE)
file_handler.setFormatter(log_formatter)
self.logger.addHandler(file_handler)
console_handler = StreamHandler()
console_handler.setFormatter(log_formatter)
self.logger.addHandler(console_handler)
def debug(self, *args, **kwargs):
self.logger.debug(*args, **kwargs)
def info(self, *args, **kwargs):
self.logger.info(*args, **kwargs)
def warning(self, *args, **kwargs):
self.logger.warning(*args, **kwargs)
def error(self, *args, **kwargs):
self.logger.error(*args, **kwargs)