]> git.pld-linux.org Git - projects/pld-builder.new.git/blob - PLD_Builder/log.py
- log.last_log() hack
[projects/pld-builder.new.git] / PLD_Builder / log.py
1 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
2
3 import sys
4 import time
5 import syslog
6
7 import path
8
9 builder = ""
10 do_syslog = 0
11
12 # string containing last log entry,
13 # as the code is flawed to get this otherwise
14 _last_log = ""
15
16 def log(p, s):
17     if do_syslog:
18         try:
19             syslog.syslog(p, str(s))
20         except TypeError:
21             syslog.syslog(p, repr(s))
22     f = open(path.log_file, "a")
23     f.write("%s [%s]: %s\n" % (time.asctime(), builder, s))
24     f.close()
25     _last_log = s
26     
27 def panic(s):
28     log(syslog.LOG_ALERT, "PANIC: %s" % s)
29     raise Exception, "PANIC: %s" % str(s)
30
31 def alert(s):
32     log(syslog.LOG_ALERT, "alert: %s" % s) 
33  
34 def error(s):
35     log(syslog.LOG_ERR, "error: %s" % s) 
36  
37 def warn(s):
38     log(syslog.LOG_WARNING, "warning: %s" % s) 
39  
40 def notice(s):
41     log(syslog.LOG_NOTICE, "notice: %s" % s) 
42
43 def open_syslog(name, f):
44     global do_syslog
45     do_syslog = 1
46     syslog.openlog(name, syslog.LOG_PID, f)
47
48 def last_log():
49     return _last_log
This page took 0.068918 seconds and 4 git commands to generate.