From 73b8047b2298d347475a5c8d9f1853052ddced57 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 17 Apr 2013 12:19:15 +0200 Subject: Add server/protocol type to rpcserver logs Add the server class name, such as [xmlserver] or [jsonserver_kerb] to the server logs. This will allow easier debugging of problems specific to a protocol or server class. --- ipaserver/rpcserver.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'ipaserver/rpcserver.py') diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py index e4be51d64..a37d3cd0f 100644 --- a/ipaserver/rpcserver.py +++ b/ipaserver/rpcserver.py @@ -308,6 +308,7 @@ class WSGIExecutioner(Executioner): args = () options = {} + e = None if not 'HTTP_REFERER' in environ: return self.marshal(result, RefererError(referer='missing'), _id) if not environ['HTTP_REFERER'].startswith('https://%s/ipa' % self.api.env.host) and not self.env.in_tree: @@ -342,6 +343,8 @@ class WSGIExecutioner(Executioner): error = InternalError() finally: os.environ['LANG'] = lang + + principal = getattr(context, 'principal', 'UNKNOWN') if name and name in self.Command: try: params = self.Command[name].args_options_2_params(*args, **options) @@ -351,13 +354,23 @@ class WSGIExecutioner(Executioner): ) # get at least some context of what is going on params = options - principal = getattr(context, 'principal', 'UNKNOWN') if error: - self.info('%s: %s(%s): %s', principal, name, ', '.join(self.Command[name]._repr_iter(**params)), e.__class__.__name__) + result_string = type(e).__name__ else: - self.info('%s: %s(%s): SUCCESS', principal, name, ', '.join(self.Command[name]._repr_iter(**params))) + result_string = 'SUCCESS' + self.info('[%s] %s: %s(%s): %s', + type(self).__name__, + principal, + name, + ', '.join(self.Command[name]._repr_iter(**params)), + result_string) else: - self.info('%s: %s', context.principal, e.__class__.__name__) + self.info('[%s] %s: %s: %s', + type(self).__name__, + principal, + name, + type(e).__name__) + return self.marshal(result, error, _id) def simple_unmarshal(self, environ): -- cgit