add hclogslog from github.com/evanphx/go-hclog-slog#144
Open
nickethier wants to merge 7 commits intomainfrom
Open
add hclogslog from github.com/evanphx/go-hclog-slog#144nickethier wants to merge 7 commits intomainfrom
nickethier wants to merge 7 commits intomainfrom
Conversation
Author
|
Builds fixed in #145 |
jooola
reviewed
Nov 12, 2024
Comment on lines
+11
to
+13
| func Adapt(l hclog.Logger) slog.Handler { | ||
| return &Handler{l: l} | ||
| } |
There was a problem hiding this comment.
Should this have a small documentation as entry point for the rest of the adapter?
| // WithAttrs returns a new Handler whose attributes consist of | ||
| // both the receiver's attributes and the arguments. | ||
| // The Handler owns the slice: it may retain, modify or discard it. | ||
|
|
Comment on lines
+192
to
+201
| prefix := h.prefix | ||
|
|
||
| if name != "" { | ||
| prefix = h.prefix + name + "." | ||
| } | ||
|
|
||
| return &Handler{ | ||
| l: h.l, | ||
| prefix: prefix, | ||
| } |
There was a problem hiding this comment.
We do not exactly return the receiver here, it's a pointer to a new handler with the same settings.
Maybe this should be:
if name == "" {
return h
}
// ...
apricote
pushed a commit
to hetznercloud/fleeting-plugin-hetzner
that referenced
this pull request
Nov 12, 2024
…g-plugin-hetzner!166) We need a logger to be able to log warnings without failing hard. The logger will be replaced by a slog logger once hclog has an adapter for slog: hashicorp/go-hclog#144
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.
After a short discussion with @evanphx we decided to pull in the code from github.com/evanphx/go-hclog-slog as a separate go module under this repo. Since
slogis becoming the community standard structured logger, it makes most sense to maintain an adapter for hclog.Code author attribution is maintained and licenses are the same.
🚨 Once this PR is merged I will cut a
hclogslog/v0.1.0tag to release the module.