feat: add stackdriver and json log options to coder server#5682
Merged
Conversation
a050167 to
2149092
Compare
2149092 to
b32b696
Compare
kylecarbs
reviewed
Jan 11, 2023
| return host == "localhost" || host == "127.0.0.1" || host == "::1" | ||
| } | ||
|
|
||
| func makeLogger(cmd *cobra.Command, cfg *codersdk.DeploymentConfig) (slog.Logger, func(), error) { |
Member
There was a problem hiding this comment.
We should add testing around this. If logging breaks in any way, we really hurt our customers.
Member
There was a problem hiding this comment.
@coadler since you can't read sinks from an instantiated logger, you could make this return ([]slog.Sink, slog.Level, func() error) instead and instantiate the logger from the caller.
deansheather
approved these changes
Jan 12, 2023
Comment on lines
+1528
to
+1529
| if cfg.Logging.Human.Value == "/dev/stderr" { | ||
| sinks = append(sinks, sloghuman.Sink(cmd.ErrOrStderr())) |
Comment on lines
+1541
to
+1550
| if cfg.Logging.JSON.Value == "/dev/stderr" { | ||
| sinks = append(sinks, slogjson.Sink(cmd.ErrOrStderr())) | ||
| } else { | ||
| fi, err := os.OpenFile(cfg.Logging.JSON.Value, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | ||
| if err != nil { | ||
| return slog.Logger{}, nil, xerrors.Errorf("open json log %q: %w", cfg.Logging.JSON.Value, err) | ||
| } | ||
| closers = append(closers, fi.Close) | ||
| sinks = append(sinks, slogjson.Sink(fi)) | ||
| } |
Member
There was a problem hiding this comment.
This whole routine could be made into a little helper function (even just a function stored in a variable at the top of this function would be good) that returns an io.Writer
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.