-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.py
More file actions
35 lines (31 loc) · 1003 Bytes
/
logger.py
File metadata and controls
35 lines (31 loc) · 1003 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
25
26
27
28
29
30
31
32
33
34
35
import os
import logging
import config
class Logger(object):
"""
Class to setup and utilize basic logging
Args:
self
name: The name of the class utilizing logging
"""
def __init__(self, name):
name = name.replace('.log','')
logger = logging.getLogger('log_namespace.%s' % name)
logger.setLevel(logging.DEBUG)
if not logger.handlers:
if not os.path.isdir(config.LOGGING_DIR):
os.mkdir('log')
file_name = os.path.join(config.LOGGING_DIR, '%s.log' % name)
handler = logging.FileHandler(file_name)
formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s %(message)s')
handler.setFormatter(formatter)
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
self._logger = logger
"""
Method to return an instance of the logger
Args:
self
"""
def get(self):
return self._logger