runbot/runbot/__init__.py
Xavier-Do 435ac449f5 [FIX] runbot: various fixes and ref
- clean thread username
- allow to write on params for debug (was mainly usefull to forbid it
at the beginning)
- imrpove some guidelines about method and actions naming/ ordering
- move some code for a cleaner organisation.
- remove some useless request.env.user (not useful anymore)
2023-09-25 10:52:16 +02:00

31 lines
915 B
Python

# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import common
from . import container
from . import wizards
import logging
import threading
from odoo.http import request
class UserFilter(logging.Filter):
def filter(self, record): # noqa: A003
message_parts = record.msg.split(' ', 2)
if message_parts[1] == '-':
uid = getattr(threading.current_thread(), 'uid', None)
if uid is None:
return True
user_name = 'user'
if hasattr(threading.current_thread(), 'user_name'):
user_name = threading.current_thread().user_name
del(threading.current_thread().user_name)
message_parts[1] = f'({user_name}:{uid})'
record.msg = ' '.join(message_parts)
return True
def runbot_post_load():
logging.getLogger('werkzeug').addFilter(UserFilter())