1
2
3
4 """
5 Define a nice way to show the messages sent to be logged.
6
7 NOTE: not used yet
8 """
9
10 import wx
11
12
13 import logging
14 import logging.handlers
15
16 from mathbench.basement.logging_utils import CreateLogger
17
18
20 """
21 A log handler that will display the logged messages (above a
22 certain priprity level) in GUI windows.
23 """
24
37
39 """
40 React to the record according to its priority level.
41 """
42 if self.handle_mapping.has_key(record.levelno):
43 self.handle_mapping[record.levelno](record)
44 logging.StreamHandler.handle(self,record)
45
47 """
48 mouf
49 """
50 dialog = wx.MessageBox(record.getMessage(), caption = "Warning", style = wx.OK | wx.ICON_WARNING)
51
53 """
54 Trigger the info contained in a record of level ERROR.
55 """
56 dialog = wx.MessageBox(record.getMessage(), caption = "Error !", style = wx.OK | wx.ICON_ERROR)
57
59 """
60 Trigger the info contained in a record of level INFO.
61 """
62 dialog = wx.MessageBox(record.getMessage(), caption = "Information...", style = wx.OK | wx.ICON_INFORMATION)
63
65 """
66 Trigger the info contained in a record of level CRITICAL.
67 """
68 dialog = wx.MessageBox(record.getMessage(), caption = "Critical Error !", style = wx.OK | wx.ICON_STOP)
69
70
71
72
73
74 if "fumehood" in __name__ or __name__ == "__main__":
75
76
77 __log_handler = FumeHoodLogHandler()
78 __MB_LOGGER = CreateLogger(__log_handler)
79
80
83
86
89
92
95
98
99
101 """
102 Send a message each time the decorated function is called.
103
104 This nifty decorator is very usefull to trace the function calls
105 """
106 def wrapper(*args, **kwargs):
107 debug("Called func.: %s (defined in %s)" % (func.__name__,func.code.co_filename))
108 return func(*args, **kwargs)
109
110 wrapper.__name__ = func.__name__
111 wrapper.__doc__ = func.__doc__
112 wrapper.__dict__.update(func.__dict__)
113 return wrapper
114
115
116
117
118 if __name__ == "__main__":
119 app = wx.PySimpleApp()
120 debug("debug message")
121 info("info message")
122 warn("warn message")
123 error("error message")
124 critical("critical message")
125 app.MainLoop()
126