Skip to content

#51: feat: improve observability via structured logging#69

Merged
Ilyes512 merged 2 commits into
mainfrom
51-improve-observability-via-structured-logging
May 16, 2026
Merged

#51: feat: improve observability via structured logging#69
Ilyes512 merged 2 commits into
mainfrom
51-improve-observability-via-structured-logging

Conversation

@Ilyes512
Copy link
Copy Markdown
Member

  • Add *slog.Logger to hooks.Load() and Hooks struct; replace slog.Default() usage in Run() with the injected logger (falls back to slog.Default() when Hooks is constructed directly in tests). Emit debug logs for trigger start, per-command invocation, and completion.

  • Add *slog.Logger parameter to template.ApplyComputed(); log each computed key resolution with source="computed".

  • Add debug logs to template.Get() (load start/end with key/computed counts) and template.Execute() (per-file action=render|verbatim|skip at debug; rendered/verbatim/skipped summary at info level).

  • Change LoadMetadata to return the actual parse error for malformed __metadata.json (missing files still return nil,nil); update all callers to log the error at debug instead of silently discarding it.

  • In pkg/cmd/template_use.go executeTemplate: log each context key with its source (values_file, arg_flag, default, prompt); pass app.Logger to hooks.Load and ApplyComputed; thread logger through promptContext and runPromptPass.

  • In pkg/cmd/root.go PersistentPreRunE: call slog.SetDefault(app.Logger) so packages using slog.Default() (registry, etc.) inherit the configured level and handler.

  • Fix silent error swallows in template_list.go, template_update.go, registry.go: log LoadMetadata and LoadStatus errors at debug. Add debug logs before/after remote status checks with consistent attribute keys (name, repo, branch, up_to_date, error_kind).

  • Add debug logs for git clone and describe calls in template_download.go and use.go (repo, dest, branch, commit, version).

  • Add "Logging" section to docs/content/docs/architecture/overview.md documenting --debug/--output=json interaction, all log points, and the consistent attribute key set.

  • Update pkg/hooks/hooks_test.go to pass a discardLogger to Load().

  • Update pkg/template/context_test.go to pass discardLogger to ApplyComputed().

  • Update TestLoadMetadata_Malformed to expect an error for malformed JSON.

Closes #51

@Ilyes512 Ilyes512 force-pushed the 51-improve-observability-via-structured-logging branch from 1d7331d to 0926330 Compare May 16, 2026 13:12
Ilyes512 and others added 2 commits May 16, 2026 17:29
- Add *slog.Logger to hooks.Load() and Hooks struct; replace slog.Default()
  usage in Run() with the injected logger (falls back to slog.Default() when
  Hooks is constructed directly in tests). Emit debug logs for trigger start,
  per-command invocation, and completion.

- Add *slog.Logger parameter to template.ApplyComputed(); log each computed
  key resolution with source="computed".

- Add debug logs to template.Get() (load start/end with key/computed counts)
  and template.Execute() (per-file action=render|verbatim|skip at debug;
  rendered/verbatim/skipped summary at info level).

- Change LoadMetadata to return the actual parse error for malformed
  __metadata.json (missing files still return nil,nil); update all callers to
  log the error at debug instead of silently discarding it.

- In pkg/cmd/template_use.go executeTemplate: log each context key with its
  source (values_file, arg_flag, default, prompt); pass app.Logger to
  hooks.Load and ApplyComputed; thread logger through promptContext and
  runPromptPass.

- In pkg/cmd/root.go PersistentPreRunE: call slog.SetDefault(app.Logger) so
  packages using slog.Default() (registry, etc.) inherit the configured level
  and handler.

- Fix silent error swallows in template_list.go, template_update.go,
  registry.go: log LoadMetadata and LoadStatus errors at debug. Add debug
  logs before/after remote status checks with consistent attribute keys
  (name, repo, branch, up_to_date, error_kind).

- Add debug logs for git clone and describe calls in template_download.go
  and use.go (repo, dest, branch, commit, version).

- Add "Logging" section to docs/content/docs/architecture/overview.md
  documenting --debug/--output=json interaction, all log points, and the
  consistent attribute key set.

- Update pkg/hooks/hooks_test.go to pass a discardLogger to Load().
- Update pkg/template/context_test.go to pass discardLogger to ApplyComputed().
- Update TestLoadMetadata_Malformed to expect an error for malformed JSON.

Closes #51

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Ilyes512 Ilyes512 force-pushed the 51-improve-observability-via-structured-logging branch from 04e2a26 to e7637c6 Compare May 16, 2026 15:29
@Ilyes512 Ilyes512 marked this pull request as ready for review May 16, 2026 15:53
@Ilyes512 Ilyes512 merged commit a6d81af into main May 16, 2026
1 check passed
@Ilyes512 Ilyes512 deleted the 51-improve-observability-via-structured-logging branch May 16, 2026 15:54
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.

Improve observability via structured logging

1 participant