]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - pkgs/core/pomona/src/log.py
Merge branch 'installer-v2'
[people/ms/ipfire-3.x.git] / pkgs / core / pomona / src / log.py
1 #!/usr/bin/python
2
3 import time
4
5 from constants import *
6
7 class Logger:
8 def __init__(self):
9 self.logfile = open(LOGFILE, "w+")
10
11 self.logline = "%s %8s: %s\n" # time, group, message
12
13 def critical(self, msg):
14 self.logfile.write(self.logline % (self.time(), "CRITICAL", msg,))
15 self.flush()
16
17 def info(self, msg):
18 self.logfile.write(self.logline % (self.time(), "INFO", msg,))
19 self.flush()
20
21 def debug(self, msg):
22 self.logfile.write(self.logline % (self.time(), "DEBUG", msg,))
23 self.flush()
24
25 def error(self, msg):
26 self.logfile.write(self.logline % (self.time(), "ERROR", msg,))
27 self.flush()
28
29 def warning(self, msg):
30 self.logfile.write(self.logline % (self.time(), "WARNING", msg,))
31 self.flush()
32
33 def stdout(self, msg):
34 self.logfile.write(self.logline % (self.time(), "STDOUT", msg,))
35 self.flush()
36 print msg
37
38 def time(self):
39 return time.strftime("%d %b %Y %H:%M:%S")
40
41 def __del__(self):
42 self.logfile.close()
43
44 def flush(self):
45 self.logfile.flush()