Change debug logging to write to AuditLog table
Flask logger output was not visible in Portainer logs or Logging page. Changed to write debug info to audit_logs table instead, which is visible on the Logging page in the UI. Changes: - Debug entries use event_type "ticket_link_debug" - User field set to "system" - Details field contains ticket info (one per line) - Visible on Settings → Logging page Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c228d6db19
commit
aea6a866c9
@ -193,13 +193,22 @@ def link_open_internal_tickets_to_run(*, run: JobRun, job: Job) -> None:
|
|||||||
except Exception:
|
except Exception:
|
||||||
rows = []
|
rows = []
|
||||||
|
|
||||||
# Debug logging
|
# Debug logging to audit log (visible in UI)
|
||||||
if rows:
|
if rows:
|
||||||
try:
|
try:
|
||||||
from flask import current_app
|
from .models import AuditLog
|
||||||
current_app.logger.info(f"[TICKET_LINK_DEBUG] Found {len(rows)} open tickets for job_id={job.id}, run_id={run.id}")
|
details = []
|
||||||
for tid, code, t_resolved, ts_resolved in rows:
|
for tid, code, t_resolved, ts_resolved in rows:
|
||||||
current_app.logger.info(f" - ticket_id={tid}, code={code}, t.resolved_at={t_resolved}, ts.resolved_at={ts_resolved}")
|
details.append(f"ticket_id={tid}, code={code}, t.resolved_at={t_resolved}, ts.resolved_at={ts_resolved}")
|
||||||
|
|
||||||
|
audit = AuditLog(
|
||||||
|
user="system",
|
||||||
|
event_type="ticket_link_debug",
|
||||||
|
message=f"Linking {len(rows)} ticket(s) to run_id={run.id} (job_id={job.id})",
|
||||||
|
details="\n".join(details)
|
||||||
|
)
|
||||||
|
db.session.add(audit)
|
||||||
|
db.session.flush()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ This file documents all changes made to this project via Claude Code.
|
|||||||
- Fixed internal and Autotask tickets being linked to new runs even after being resolved by removing date-based "open" logic from ticket query (tickets now only link to new runs if they are genuinely unresolved, not based on run date comparisons)
|
- Fixed internal and Autotask tickets being linked to new runs even after being resolved by removing date-based "open" logic from ticket query (tickets now only link to new runs if they are genuinely unresolved, not based on run date comparisons)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Added debug logging to ticket linking function to troubleshoot resolved ticket propagation issues (logs ticket_id, ticket_code, resolved_at values for both ticket and scope)
|
- Added debug logging to ticket linking function to troubleshoot resolved ticket propagation issues (writes to AuditLog table with event_type "ticket_link_debug", visible on Logging page, shows ticket_id, ticket_code, resolved_at values for both ticket and scope)
|
||||||
|
|
||||||
## [2026-02-09]
|
## [2026-02-09]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user