Add contextual action diagnostics to support logs before beta
Context
The current application log contains structured API request ids, status codes and durations, but the context is often empty. In the sample log, most structured API lines had job_key, profile_key and location set to empty strings. That makes the log hard to use when a tester reports that a specific job, repository, storage profile, Apprise profile or migration did not behave as expected.
After reducing routine log noise, the remaining lines should carry enough sanitized context to answer what object was touched and what phase failed.
Goal
Make important application actions self-describing in the support log by adding relevant, sanitized context fields.
Scope
Add context to important API and internal action logs, including:
- Backup jobs:
job_keybackup_typelocationrepositoryor repository identifier where safe- source of request, such as manual, schedule or API token
- Restore and restore tests:
job_key- restore run id or restore-test level where available
- repository or archive identifier where safe
- Storage and repositories:
profile_key- storage type
- repository key/path where safe
- operation phase such as check, mount, browse, create, import or maintenance
- Apprise notification profiles:
profile_id- display name where safe
- provider
- event type
- operation phase such as validate, test, queue, deliver or delete
- Migrations and system health:
migration_id- phase
- status
- actionable reason without secrets
- Auth/security events:
- keep request id and endpoint
- keep target username when safe
- avoid exposing session ids or tokens
Acceptance criteria
- Important write/action API calls no longer emit empty context when the request contains a meaningful object id.
- Job run requests include at least
request_id,job_key, request source and response status. - Apprise profile validation/test/delete operations include
profile_idand provider when available. - Storage/repository operations include storage or repository identifiers where available and safe.
- Migration failures or blocked states include
migration_id, phase and sanitized reason. - Context is consistently serialized and remains parseable in plain text logs.
- Secrets, tokens, passwords, passphrases, full Apprise URLs and sensitive export data are never logged.
- Tests cover representative context extraction for jobs, Apprise profiles, storage/repositories and migration failures.
Suggested implementation
- Extend the existing
_request_context()or equivalent request context extraction inborg_backup_ui.py. - Derive context from path parameters, query parameters and parsed JSON bodies.
- Add helpers for safe context normalization and secret masking.
- Prefer stable identifiers over verbose payloads.
- Keep context small; the support log should identify the object, not dump full API requests.
Example target lines
API ok request_id=... status=200 method=POST path=/api/jobs/run duration_ms=45 bytes=86 context={"job_key":"appdata_local","source":"manual"}
APPRISE test request_id=... profile_id=alerts-main provider=ntfy result=ok duration_ms=820
MIGRATION status migration_id=canonical_backup_conf_v1 phase=detect status=ok action=none
STORAGE check request_id=... profile_key=nas-smb storage_type=smb phase=mount result=ok
Notes
This is stage 2 of the pre-beta support logging work. It depends on the stage 1 direction so that the enriched lines are not buried under routine polling noise.
Closed via merged PR #274.