It’s actually a great idea!
main ← automation-error-tracking-and-logging
opened 10:18PM - 01 Jan 26 UTC
When automations fail silently (e.g., PM sending blocked due to validation error… s), admins have no visibility into what's going wrong. This leaves them guessing why their automations aren't working as expected.
This change addresses the problem in three ways:
1. Error tracking in automation stats
The Stat model now tracks `total_errors` alongside existing run metrics. When an automation raises an exception during execution, it's caught and counted. This gives admins visibility into which automations are experiencing problems.
2. Centralized logging module
Created `DiscourseAutomation::Logger` to replace scattered `Rails.logger.warn("[discourse-automation] ...")` calls throughout the codebase. This eliminates the fragile manual prefix pattern and ensures consistent log formatting across all automation code. All existing logging calls have been migrated to use this module.
3. Error count display in admin UI
The automation list now shows recent error counts next to run statistics. Clicking the error count links directly to `/logs` filtered for discourse-automation entries, making it easy to investigate failures. The link uses `data-auto-route="true"` to ensure proper navigation outside Ember's client-side router.
<img width="1397" height="1041" alt="2026-01-01 @ 23 03 34" src="https://github.com/user-attachments/assets/6a6733f1-999c-44de-ab04-78dd764a1a43" />
Ref - https://meta.discourse.org/t/389922
The diff looks big but it’s mostly because I centralized how we log in the automation plugin so that we always have the [discourse-automation] prefix so all the logs can be searched with it.
2 Likes