diff --git a/rhodecode/lib/auth.py b/rhodecode/lib/auth.py --- a/rhodecode/lib/auth.py +++ b/rhodecode/lib/auth.py @@ -1541,8 +1541,7 @@ class AuthUser(object): return notice_messages, notice_level def __repr__(self): - return ""\ - % (self.user_id, self.username, self.ip_addr, self.is_authenticated) + return self.repr_user(self.user_id, self.username, self.ip_addr, self.is_authenticated) def set_authenticated(self, authenticated=True): if self.user_id != self.anonymous_user.user_id: @@ -1557,6 +1556,11 @@ class AuthUser(object): } @classmethod + def repr_user(cls, user_id=0, username='ANONYMOUS', ip='0.0.0.0', is_authenticated=False): + tmpl = "" + return tmpl.format(user_id, username, ip, is_authenticated) + + @classmethod def from_cookie_store(cls, cookie_store): """ Creates AuthUser from a cookie store diff --git a/rhodecode/lib/middleware/request_wrapper.py b/rhodecode/lib/middleware/request_wrapper.py --- a/rhodecode/lib/middleware/request_wrapper.py +++ b/rhodecode/lib/middleware/request_wrapper.py @@ -22,8 +22,9 @@ import time import logging import rhodecode +from rhodecode.lib.auth import AuthUser from rhodecode.lib.base import get_ip_addr, get_access_path, get_user_agent -from rhodecode.lib.utils2 import safe_str +from rhodecode.lib.utils2 import safe_str, get_current_rhodecode_user log = logging.getLogger(__name__) @@ -46,9 +47,11 @@ class RequestWrapperTween(object): total = end - start count = request.request_count() _ver_ = rhodecode.__version__ + default_user_info = AuthUser.repr_user(ip=get_ip_addr(request.environ)) + user_info = get_current_rhodecode_user(request) or default_user_info log.info( - 'Req[%4s] IP: %s %s Request to %s time: %.4fs [%s], RhodeCode %s', - count, get_ip_addr(request.environ), request.environ.get('REQUEST_METHOD'), + 'Req[%4s] %s %s Request to %s time: %.4fs [%s], RhodeCode %s', + count, user_info, request.environ.get('REQUEST_METHOD'), safe_str(get_access_path(request.environ)), total, get_user_agent(request. environ), _ver_ )