Commit 91d714a1 authored by Vidjil Team's avatar Vidjil Team

db.py: evaluates request.client in LoggerAdapter

Before, it was evaluated once at logger creation.
parent 5b2798a6
......@@ -206,7 +206,7 @@ class MsgUserAdapter(logging.LoggerAdapter):
def process(self, msg, kwargs):
if type(msg) is dict:
msg = msg['message']
new_msg = '<%s> %s' % ((auth.user.first_name if auth.user else ''), msg)
new_msg = '%15s <%s> %s' % (request.client, (auth.user.first_name if auth.user else ''), msg)
return new_msg, kwargs
#
......@@ -223,7 +223,7 @@ def _init_log():
logger.setLevel(logging.DEBUG)
handler = logging.FileHandler('/var/vidjil/vidjil.log')
handler.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter('%s' % request.client + ' [%(process)d] %(asctime)s - %(levelname)s %(filename)s:%(lineno)d - %(message)s'))
handler.setFormatter(logging.Formatter('[%(process)d] %(asctime)s %(levelname)8s - %(filename)s:%(lineno)d\t%(message)s'))
logger.addHandler(handler)
logger.info("Creating logger")
return MsgUserAdapter(logger, {})
......
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