-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[16.0][ADD] server_action_logging #2928
Conversation
49b95f7
to
a30063f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things to fix.
Please add more comments, and unit tests.
# Copyright 2020 Acsone (http://www.acsone.eu) | ||
# Nans Lefebvre <nans.lefebvre@acsone.eu> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad copypaste, I assume 😄
DEFAULT_LOG_CONFIGURATION = [ | ||
"odoo.http.rpc.request:INFO", | ||
"odoo.http.rpc.response:INFO", | ||
":INFO", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better inheritability, please create a function in model ir.actions.server
that returns this list, instead of a global variable.
Also: mind explaining in a comment why you chose these values?
) | ||
|
||
def run(self): | ||
log_handlers = DEFAULT_LOG_CONFIGURATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log_handlers
is used only by method _update_logger_level()
, so you can avoid defining this variable here, and retrieve the handlers directly within _update_logger_level()
return res or False | ||
|
||
def _update_logger_level(self, log_handlers, reset=False): | ||
# check odoo/src/odoo/netsvc.py:260 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unknown path 😅
Please add a URL with the GitHub reference (commit included), for example:
github.com/odoo/odoo/blob/ca5a8b3/odoo/netsvc.py#L267
try: | ||
res = super(IrActionsServer, action).run() | ||
finally: | ||
_logger.info( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will ignore exceptions raised by the super().run()
method. Please add an except
clause where exceptions are logged (including the action duration before failing) and then raised (as it happens in the standard method).
"Action with id %s and name %s took %s seconds", | ||
action.id, | ||
action.name, | ||
fields.Datetime.now() - start_time, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use timedelta.total_seconds()
method if you want to display duration in seconds.
superseeded by #2945 |
No description provided.