From 00779de8d324bfc25f358084e182ecdeb397374d Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Sat, 22 Apr 2023 08:52:29 -0500 Subject: [PATCH] Cron logging improvements. --- files/commands/cron.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/files/commands/cron.py b/files/commands/cron.py index c55c0a10c..a905e88ee 100644 --- a/files/commands/cron.py +++ b/files/commands/cron.py @@ -116,10 +116,12 @@ def _run_tasks(db_session_factory: scoped_session): task.run_time_last = now task.run_state_enum = ScheduledTaskState.RUNNING + task_debug_identifier = f"(ID {task.id}:{task.label})" + logging.info(f"Running task {task_debug_identifier}") + db.begin() run: RepeatableTaskRun = task.run(db, task.run_time_last_or_created_utc) - task_debug_identifier = f"(ID {run.task_id}:{task.label}, run ID {run.id})" - logging.info(f"Running task {task_debug_identifier}") + if run.exception: # TODO: collect errors somewhere other than just here and in the # task run object itself (see #220).