-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom_logger.py
More file actions
24 lines (22 loc) · 825 Bytes
/
Copy pathcustom_logger.py
File metadata and controls
24 lines (22 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Common logger object to maintain logs"""
import logging
class Logger:
"""
Initalize a logger file with logFileName
"""
def __init__(self, log_file_name):
self.log_file_name = log_file_name
self.log_file_path = 'logs/' + log_file_name
def get_logger(self):
"""
Get a logger
:return: logger object
"""
# Initialize logger
logging.basicConfig(filename=self.log_file_path,
filemode='w',
format='%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d]'
' %(message)s',
datefmt='%Y-%m-%d:%H:%M:%S',
level=logging.DEBUG)
return logging.getLogger(self.log_file_name.split('.')[0])