[Sugar-devel] SL Bug #2063
Mukul Gupta
mukul at seeta.in
Sun Oct 10 15:14:35 EDT 2010
With reference to SL Bug # 2063 which deals with bringing some kind of
notification alert whenever an unhandled python exception occurs, I had a
few doubts. There are two approaches that I can think of.
1. Any unhandled python exception is always logged. Thus, if we can check
whenever logging.ERROR has been called, there ,an exception has occured
.Thus if we introduce a flag which attains True value when an exception
occurs, and by checking the value of the flag in a GUI file we can generate
an alert/notification. For this purpose, I have tried to get a git diff of
the sugar.logger .
However, I have a doubt whether it is through this logger.py file through
which logging is taken place . I see the file not being imported by journal
files,etc.
diff --git a/logger.py b/logger.py
index 6a6b574..fd079dc 100644
--- a/logger.py
+++ b/logger.py
@@ -43,6 +43,9 @@ _LEVELS = {
'trace': TRACE,
'all': 0,
}
+
+CHECK_ALERT = False
+
logging.addLevelName(TRACE, 'TRACE')
@@ -57,8 +60,9 @@ def get_logs_dir():
def set_level(level):
if level in _LEVELS:
logging.getLogger('').setLevel(_LEVELS[level])
- return
-
+ alert_log_exception(level)
+ return
+
try:
logging.getLogger('').setLevel(int(level))
except ValueError:
@@ -203,3 +207,8 @@ def trace(logger=None, logger_name=None, skip_args=None,
skip_kwargs=None,
return res
return decorator.decorator(_trace)
+
+def alert_log_exception(level):
+ if level == 'error'
+ CHECK_ALERT = True
+
--
1.7.0.4
2. Alternatively, if we can make a new file that reads the shell.log line by
line and whenever ERROR: is encountered, an alert is raised. However, for
this the new file has to be active at all times.
It would be great if you could shed some light on what approach should I
follow or suggest an alternative way to this problem.
Waiting for your response and valuable suggestions,
Regards,
Mukul Gupta
Research Engineer,SEETA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101011/45a22283/attachment.html>
More information about the Sugar-devel
mailing list