]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - src/pomona/log.py
84608939ab544a19d08bc1daf9e9308a048e0a20
[people/ms/ipfire-3.x.git] / src / pomona / 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
16 def info(self, msg):
17 self.logfile.write(self.logline % (self.time(), "INFO", msg,))
18
19 def debug(self, msg):
20 self.logfile.write(self.logline % (self.time(), "DEBUG", msg,))
21
22 def error(self, msg):
23 self.logfile.write(self.logline % (self.time(), "ERROR", msg,))
24
25 def warning(self, msg):
26 self.logfile.write(self.logline % (self.time(), "WARNING", msg,))
27
28 def stdout(self, msg):
29 self.logfile.write(self.logline % (self.time(), "STDOUT", msg,))
30 print msg
31
32 def time(self):
33 return time.strftime("%d %b %Y %H:%M:%S")
34
35 def __del__(self):
36 self.logfile.close()