Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

imlopes
Copy link

@imlopes imlopes commented Apr 30, 2024

No description provided.

Copy link
Contributor

@SilvioC2C SilvioC2C left a 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.

Comment on lines +1 to +2
# Copyright 2020 Acsone (http://www.acsone.eu)
# Nans Lefebvre <nans.lefebvre@acsone.eu>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad copypaste, I assume 😄

Comment on lines +9 to +13
DEFAULT_LOG_CONFIGURATION = [
"odoo.http.rpc.request:INFO",
"odoo.http.rpc.response:INFO",
":INFO",
]
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

Comment on lines +36 to +39
try:
res = super(IrActionsServer, action).run()
finally:
_logger.info(
Copy link
Contributor

@SilvioC2C SilvioC2C May 6, 2024

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,
Copy link
Contributor

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.

@SilvioC2C
Copy link
Contributor

@imlopes can you please close this PR, which is now superseded by #2945?

@gurneyalex
Copy link
Member

superseeded by #2945

@gurneyalex gurneyalex closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants