-
Notifications
You must be signed in to change notification settings - Fork 1
/
mLogger.py
executable file
·41 lines (30 loc) · 1.2 KB
/
mLogger.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
# logging
import logging, logging.handlers
# forcing ram cleaning
import gc
# enable full error tracing in responses
import traceback
class logee:
global logger
def __init__(self, log_file_name, app_name ):
# logging configuration
LOG_FILENAME = log_file_name # 'collaboration.log'
# create logger
self.logger = logging.getLogger(app_name)#"rtpa-collaboration-analysis-class Dbpedia")
self.logger.setLevel(logging.DEBUG)
# create console handler and set level to debug
consolehandler = logging.StreamHandler()
# Add the log message handler to the logger
logFilehandler = logging.handlers.RotatingFileHandler(
LOG_FILENAME, maxBytes=20000000, backupCount=5)
consolehandler.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
# add formatter to ch
consolehandler.setFormatter(formatter)
logFilehandler.setFormatter(formatter)
# add ch to logger
self.logger.addHandler(consolehandler)
self.logger.addHandler(logFilehandler)
# enabling garabage collector
gc.enable()