#51: feat: improve observability via structured logging#69
Merged
Conversation
1d7331d to
0926330
Compare
- 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>
04e2a26 to
e7637c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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