-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.py
executable file
·34 lines (27 loc) · 959 Bytes
/
logger.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
class Logger(object):
Initialized = False
@staticmethod
def initialize(path_to_log_file):
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
handlers=[logging.FileHandler(path_to_log_file),
logging.StreamHandler()])
Logger.Initialized = True
@staticmethod
def log(level, message):
assert Logger.Initialized, 'Logger has not been initialized'
logging.log(level, message)
@staticmethod
def d(message):
Logger.log(logging.DEBUG, message)
@staticmethod
def i(message):
Logger.log(logging.INFO, message)
@staticmethod
def w(message):
Logger.log(logging.WARNING, message)
@staticmethod
def e(message):
Logger.log(logging.ERROR, message)