Repository navigation
Added ctx object to all system struct's constructors - #837
Merged
Merged
Conversation
The idea behind this commit is to set the stage for adding aditional logging metadata.
* Added new flags `--log-level` and `-l` to be consistent with other goss flags. * `--loglevel` and `-L` will be deprecated in a future release * Log level accepts any casing, so DEBUG and debug are both valid cli opts * Add log level support for `add` and `autoadd` commands
aelsabbahy
force-pushed
the
add_ctx_simple
branch
from
September 10, 2023 21:38
eabf6e9 to
cd28eac
Compare
ripienaar
reviewed
Sep 11, 2023
| } | ||
|
|
||
| func (c *Command) Validate(sys *system.System) []TestResult { | ||
| ctx := context.WithValue(context.Background(), "id", c.ID()) |
Collaborator
There was a problem hiding this comment.
Using context values for this is ok, but probably more idiomatic these days to use a structured logger like the (new) slog or something like logrus and then pass that down with key-vals added.
Member
Author
There was a problem hiding this comment.
I'm very interested to see what ends up as idiomatic with the introduction of slog.
Seems like it's been a heavily debated topic: golang/go#58243
I'm okay with pivoting to whatever becomes the norm once the dust settles a bit on slog and patterns emerge.
Member
Author
|
Seems a bit of work piled up, going to start merging it.. since it's internal to the app we can revisit/change in a future PR. |
3 tasks
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.
The idea behind this commit is to set the stage for adding additional logging metadata.
Added logging support for command as an example.
Checklist
make test-all(UNIX) passes. CI will also test thisDescription of change
This is the simpler version of #836 it goes against the guidance here but it is a much simpler (and cleaner?) implementation.
Also, this approach didn't break any of the unit tests, like #836 did.