Commit 7a8eb29b authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Astakos logging fixes

Removed with_logging wrapper which inconsistently extracted user/request
arguments. Logging statements placed explicitly within login/logout

Fix admin notification logging
parent d1f3cfca
......@@ -85,23 +85,6 @@ import as astakos_messages
logger = logging.getLogger(__name__)
def logged(func, msg):
def with_logging(*args, **kwargs):
email = ''
user = None
request = args[0]
email =
except (KeyError, AttributeError), e:
email = ''
r = func(*args, **kwargs)
logger.log(LOGGING_LEVEL, msg % email)
return r
return with_logging
def login(request, user):
auth_login(request, user)
from import SessionCatalog
......@@ -109,9 +92,13 @@ def login(request, user):
).save()'%s logged in.', user.log_display)
login = logged(login, '%s logged in.')
logout = logged(auth_logout, '%s logged out.')
def logout(request, *args, **kwargs):
user = request.user
auth_logout(request, *args, **kwargs)'%s logged out.', user.log_display)
def send_verification(user, template_name='im/activation_email.txt'):
......@@ -168,8 +155,8 @@ def _send_admin_notification(template_name,
raise SendNotificationError()
msg = 'Sent admin notification for user %s' % dictionary.get('email',
msg = 'Sent admin notification for user %s' % \
(dictionary.get('user', {}).get('email', None), )
logger.log(LOGGING_LEVEL, msg)
......@@ -410,6 +410,14 @@ class AstakosUser(User):
def realname(self):
return '%s %s' % (self.first_name, self.last_name)
def log_display(self):
Should be used in all logger.* calls that refer to a user so that
user display is consistent across log entries.
return '%s (%s)' % (self.uuid,
def realname(self, value):
parts = value.split(' ')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment