-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_manager.py
49 lines (35 loc) · 1005 Bytes
/
log_manager.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
39
40
41
42
43
44
45
46
47
48
49
import utils
SEVERITY_FINE = 1
SEVERITY_WARNING = 2
SEVERITY_ERROR = 3
STR_SEVERITY = {
SEVERITY_FINE : "FINE"
SEVERITY_WARNING : "WARNING"
SEVERITY_ERROR : "ERROR"
}
LOG_TEMPLATE = "%s %s: %s\n"
class log_manager():
__logfile=None
__repoman=None
def __init__(self, repoman):
self.__repoman=repoman
def setLogFile(self, logfile):
self.__logfile = logfile
def log(self, severity, message):
msg = LOG_TEMPLATE % (utils.getTimeStamp(), STR_SEVERITY[severity], message)
#If the log file is set log to the file.
if self.__logfile != None:
# Log to file
# Log to the console as well
print msg
def logFine(self, message):
self.log(SEVERITY_FINE, message)
def logWarning(self, message):
self.log(SEVERITY_WARNING, message)
def logError(self, message):
self.log(SEVERITY_ERROR, message)
class LogException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)