Re: [Spacewalk-devel] Python server: better logging of exceptions

2013-11-15 Thread Milan Zazrivec
 Exceptions raised by the python server are not logged as errors, this
 could result in most of them to be missing from the log files.
 
 I noticed that when some code I added to the python server caused an
 internal exception: the logs didn't contain any useful information

Heya Flavio, thank you for your patch.

We discussed your proposed change in the team and we agreed that:

1. The first two log_debugs should stay log_debugs, since here our application
is catching our user-defined schema exceptions, it's not really an error
in the application (just an exceptional case in our application).

2. The other three log_debug - log_error changes are legitimate, since yes,
we are actually dealing with an error in application and are rolling back
afterwards.

If you could please send an updated patch, I will gladly apply it to
spacewalk.git.

Thank you
-Milan Zázrivec

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] Python server: better logging of exceptions

2013-11-12 Thread Flavio Castelli
Exceptions raised by the python server are not logged as errors, this
could result in most of them to be missing from the log files.

I noticed that when some code I added to the python server caused an
internal exception: the logs didn't contain any useful information

Cheers
Flavio

-- 
Flavio Castelli
SUSE LINUX Products GmbH
Maxfeldstraße 5, 90409 Nürnberg Germany
From 30cd21a0d00a4c7fae72bbf1f2aebe530117359a Mon Sep 17 00:00:00 2001
From: Flavio Castelli fcaste...@suse.com
Date: Tue, 12 Nov 2013 11:40:39 +0100
Subject: [PATCH] python server: better logging of exceptions

Ensured all the exceptions are logged, no matter which log level is
being used by the logger.
---
 backend/server/apacheRequest.py | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/backend/server/apacheRequest.py b/backend/server/apacheRequest.py
index 145189a..84ea623 100644
--- a/backend/server/apacheRequest.py
+++ b/backend/server/apacheRequest.py
@@ -151,13 +151,13 @@ class apacheRequest:
 except rhnSQL.SQLSchemaError, e:
 f = None
 if e.errno == 20200:
-log_debug(2, User Group Membership EXCEEDED)
+log_error(User Group Membership EXCEEDED)
 f = rhnFault(43, e.errmsg)
 elif e.errno == 20220:
-log_debug(2, Server Group Membership EXCEEDED)
+log_error(Server Group Membership EXCEEDED)
 f = rhnFault(44, e.errmsg)
 if not f:
-log_debug(4, rhnSQL.SQLSchemaError caught, e)
+log_error(rhnSQL.SQLSchemaError caught, e)
 rhnSQL.rollback()
 # generate the traceback report
 Traceback(method, self.req,
@@ -166,13 +166,14 @@ class apacheRequest:
 return apache.HTTP_INTERNAL_SERVER_ERROR
 response = f.getxml()
 except rhnSQL.SQLError, e:
-log_debug(4, rhnSQL.SQLError caught, e)
+log_error(rhnSQL.SQLError caught, e)
 rhnSQL.rollback()
 Traceback(method, self.req,
   extra=SQL Error generated: %s % e,
   severity=schema)
 return apache.HTTP_INTERNAL_SERVER_ERROR
-except:
+except Exception, e:
+log_error(Unhandled exception, e)
 rhnSQL.rollback()
 # otherwise we do a full stop
 Traceback(method, self.req, severity=unhandled)
-- 
1.8.1.4

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel