Commit 9cb95de4 authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Vidjil Team
Browse files add logging capabilities

This should rather be in 'modules/', but I don't manage to get the 'import' working
parent ca802b21
......@@ -196,3 +196,41 @@ if db( > 0).count() == 0:
## after defining tables, uncomment below to enable auditing
## Logging
import logging
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)
return new_msg, kwargs
def _init_log():
adapted from
import logging
logger = logging.getLogger('vidjil') # (request.application)
if not logger.handlers:
handler = logging.FileHandler('/var/vidjil/vidjil.log')
handler.setFormatter(logging.Formatter('%s' % request.client + ' [%(process)d] %(asctime)s - %(levelname)s %(filename)s:%(lineno)d - %(message)s'))
logger.addHandler(handler)"Creating logger")
return MsgUserAdapter(logger, {})
log = _init_log()
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