Skip to content

feat: add toggleable debug logging#18

Merged
joaoferrete merged 7 commits into
mainfrom
jf-feat/debug-logging
Jun 5, 2026
Merged

feat: add toggleable debug logging#18
joaoferrete merged 7 commits into
mainfrom
jf-feat/debug-logging

Conversation

@joaoferrete

Copy link
Copy Markdown
Owner

Summary

  • New debug_log.py module: init() / enable() / log() — writes structured lines to logs/debug-YYYY-MM-DD.log (daily rotation). Never raises, no-op when disabled.
  • Toggle in Settings → Preferences → Debug logging — takes effect immediately without restart. Shows the log path when enabled.
  • logs/ added to .gitignore; debug_log added to py-modules for system-wide install.

What gets logged:

Category Events
[SYNC] Hevy full/incremental start & complete (counts), Google Fit sync start & complete
[AI] Token usage per request (provider, model, input/output/cache), coaching report start
[ERROR] AI exceptions with provider, model, status code, last traceback line
[PROFILE] Profile create, activate, rename, delete

Example log lines:

2026-06-05 13:42:01 [SYNC   ] Hevy incremental sync complete  updated=3  deleted=0  routines=12
2026-06-05 13:42:05 [AI     ] Token usage  provider=gemini  model=gemini-2.5-pro  input=1234  output=567  cache_read=890
2026-06-05 13:43:25 [ERROR  ] ClientError: 403 PERMISSION_DENIED  provider=gemini  model=gemini-flash-latest  status=403

Test plan

  • pytest tests/ — 264 passed, no regressions
  • Toggle on → logs appear in logs/debug-YYYY-MM-DD.log after sync/AI request
  • Toggle off → no further lines written
  • make install picks up debug_log module in system-wide install

🤖 Generated with Claude Code

joaoferrete and others added 4 commits June 5, 2026 11:05
New debug_log module writes structured lines to logs/debug-YYYY-MM-DD.log
(daily rotation) when the setting is enabled. Toggle via
Settings → Preferences → Debug logging — takes effect immediately,
no restart needed.

Events logged:
- [SYNC]    Hevy full/incremental sync start & complete (counts)
- [SYNC]    Google Fit sync start & complete (counts)
- [AI]      Token usage per request (provider, model, in/out/cache)
- [AI]      Coaching report start (provider, model, weeks)
- [ERROR]   AI exceptions with provider, model, status, traceback line
- [PROFILE] Profile create, activate, rename, delete

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…TRIBUTING

README: new "Debug logs" section explaining how to enable, what is
captured per category, and an example of the log format.

CONTRIBUTING: new "Reporting bugs" section at the top asking for
steps to reproduce, screenshots/terminal output, the debug log, and
environment details.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
New log categories and events:
- [APP]     Startup (profile, provider, model) and clean exit
- [MENU]    Every main menu selection
- [SYNC]    Fresh-data skip, auto-sync trigger, user accept/decline for
            both Hevy and Google Fit
- [GOAL]    Goal created (type only, no personal content)
- [SETTING] Every user-initiated settings change (key + new value)
- [RESET]   Memories cleared, goals cleared, sync state reset, full wipe
- [AI]      Chat session start (provider, model, weeks, slim, language),
            tool calls (push_routine / update_routine / manage_goals),
            session end (turn count), memories extracted count,
            coaching report complete (token delta)

Personal data is never written: goal descriptions, body targets, and
per-session token counts are omitted from all log lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- [SYNC]    Manual sync: type chosen (full/incremental)
- [GOAL]    Weekly check-in result (confirmed/update/skipped)
- [GOAL]    Goals reset from "start from scratch" in goals menu
- [GOAL]    First-run goals wizard accepted/declined
- [GOAL]    Weekly check-in triggered
- [AI]      Coaching report: weeks requested; error with type
- [SETTING] Google Fit connected / disconnected
- [ERROR]   Google Fit connect failures (credentials missing, auth error)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joaoferrete joaoferrete self-assigned this Jun 5, 2026
joaoferrete and others added 3 commits June 5, 2026 11:24
cli.py:
- [MENU]    Stats viewed (weeks), Progression viewed (type + weeks),
            Records viewed, Goals action selected (view/update/reset)
- [GOAL]    Goals wizard completed (total, mode)
- [AI]      Chat weeks requested
- [PROFILE] Migration completed, first-run profile created,
            multi-profile selection at startup,
            profile switch requested (from→to),
            switched to newly created profile
- [ERROR]   Google Fit sync error from _do_fit()

ai/coach.py:
- [AI]      Routine push confirmed → Hevy (routine_id, exercise count)
- [AI]      Routine update confirmed → Hevy (routine_id)
- [AI]      Routine push/update declined by user
- [AI]      Goal change (add/update/remove) applied
- [AI]      Goal change declined by user
- [ERROR]   Routine push/update failures
- [ERROR]   Goal change failures

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Expands the "What is logged" table from 6 rows to all 9 categories
(APP, MENU, SYNC, GOAL, AI, SETTING, PROFILE, RESET, ERROR) with
complete event descriptions. Updates the example log snippet to show
a realistic end-to-end session. Adds a note that personal data is
never written to logs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- What it does: add Profiles and Debug logs feature rows; expand Settings row
- Setup step 3: correct path from Settings → Profiles to Settings → Profile
  for updating the Hevy API key
- Settings → Profile: add Hevy API key row
- Settings → Preferences: add Debug logging row
- Reset data: update manual sqlite/rm commands to use profiles/{slug}/ paths
  instead of the old root hevy.db and fit_token.json paths
- Architecture: add profile_mgr.py and debug_log.py; replace root hevy.db /
  fit_token.json with the profiles/{slug}/ directory structure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@joaoferrete joaoferrete merged commit 64b834b into main Jun 5, 2026
5 checks passed
@joaoferrete joaoferrete deleted the jf-feat/debug-logging branch June 5, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant