Skip to content

Commit

Permalink
[IMP] base: log job duration
Browse files Browse the repository at this point in the history
Log the job duration of the usual `INFO` level for easier monitoring.

closes odoo#149881

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
  • Loading branch information
nim-odoo committed Jan 23, 2024
1 parent be782dd commit 85c06dd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions odoo/addons/base/models/ir_cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,12 @@ def _callback(self, cron_name, server_action_id, job_id):

log_depth = (None if _logger.isEnabledFor(logging.DEBUG) else 1)
odoo.netsvc.log(_logger, logging.DEBUG, 'cron.object.execute', (self._cr.dbname, self._uid, '*', cron_name, server_action_id), depth=log_depth)
start_time = False
_logger.info('Starting job `%s`.', cron_name)
if _logger.isEnabledFor(logging.DEBUG):
start_time = time.time()
start_time = time.time()
self.env['ir.actions.server'].browse(server_action_id).run()
_logger.info('Job `%s` done.', cron_name)
end_time = time.time()
_logger.info('Job done: `%s` (%.3fs).', cron_name, end_time - start_time)
if start_time and _logger.isEnabledFor(logging.DEBUG):
end_time = time.time()
_logger.debug('%.3fs (cron %s, server action %d with uid %d)', end_time - start_time, cron_name, server_action_id, self.env.uid)
self.pool.signal_changes()
except Exception as e:
Expand Down

0 comments on commit 85c06dd

Please sign in to comment.