[IMP] base: log job duration

Log the job duration of the usual `INFO` level for easier monitoring.

closes odoo/odoo#149881

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2024-01-23 18:27:42 +00:00
parent be782ddde5
commit 85c06dd3ae
+3 -5
View File
@@ -371,14 +371,12 @@ class ir_cron(models.Model):
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: