-
Notifications
You must be signed in to change notification settings - Fork 6
/
msglog.py
executable file
·48 lines (33 loc) · 882 Bytes
/
msglog.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
#!/usr/bin/env python3
import sys
##################################################################
# MsgLog: Print messages and also batch them up to print at the end:
#
class MsgLog:
def __init__(self):
self.msgstr = ""
self.errstr = ""
def msg(self, s):
self.msgstr += "\n" + s
print("MESSAGE:", s, file=sys.stderr)
def warn(self, s):
self.msgstr += "\n" + s
print("WARNING:", s, file=sys.stderr)
def err(self, s):
self.errstr += "\n" + s
print("ERROR:", s, file=sys.stderr)
def get_msgs(self):
return self.msgstr
def get_errs(self):
return self.errstr
gMsglog = MsgLog()
def msg(s):
gMsglog.msg(s)
def warn(s):
gMsglog.warn(s)
def err(s):
gMsglog.err(s)
def get_msgs():
return gMsglog.get_msgs()
def get_errs():
return gMsglog.get_errs()