Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 45 lines (33 sloc) 0.727 kb
df02500 Richo Healey initial import
authored
1 import time
2 import sys
3
4 LOGFILE='pyBawt.log'
5
6 def with_log(func):
7 def _(msg):
8 fh = open(LOGFILE, 'a')
9 func(msg, fh)
10 fh.close()
11 return _
12
13 @with_log
14 def log(msg, fh):
15 if not msg.endswith("\n"):
16 msg += "\n"
17 fh.write(msg)
18
19 def fmt(msg):
20 return "%s | %s" % (time.asctime(), msg)
21
22 def error(msg):
23 log("E: %s" % fmt(msg))
24
25 def info(msg):
26 log("I: %s" % fmt(msg))
27
28 def warn(msg):
29 log("W: %s" % fmt(msg))
30
31 def fixme(msg):
32 log("X: %s" % fmt(msg))
33
34 def fatal(msg):
35 log("F: %s" % fmt(msg))
095cb46 Richo Healey Newlines at the end of stderr messages
authored
36 sys.stderr.write(fmt(msg) + "\n")
df02500 Richo Healey initial import
authored
37 exit(1)
38
39 class Writer(object):
40 def __init__(self, func):
41 self.func = func
42 def write(self, msg):
43 self.func(msg)
44
Something went wrong with that request. Please try again.