Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable human logger #80

Closed
deansheather opened this issue Dec 18, 2019 · 4 comments
Closed

Configurable human logger #80

deansheather opened this issue Dec 18, 2019 · 4 comments
Labels

Comments

@deansheather
Copy link
Member

The human logger should allow for a configuration struct which lets the developer hide things like the timestamp and file name. We could also allow for forcibly disabling colors through this config struct too.

package sloghuman

type Config struct {
    HideTimestamp bool
    HideFile bool
    ...
}

func MakeConfig(w io.Writer, c Config) slog.Logger {}
@nhooyr
Copy link
Contributor

nhooyr commented Dec 19, 2019

The lack of customization was intentional. When would you want to hide timestamps or location stamps?

Location stamps I could see being an IP leak but I would consider that a stretch and outweighed by the debugging benefits.

@deansheather
Copy link
Member Author

For example, if you wanted to output to a log file with full output and output to stderr with only the level, message and fields. This could be useful in a CLI app, because the timestamp and filename clutter up every log line.

@nhooyr
Copy link
Contributor

nhooyr commented Dec 19, 2019

This could be useful in a CLI app, because the timestamp and filename clutter up every log line.

slog is not a good choice for a CLI app. CLI messages are purely for humans and so log.Printf is likely much better.

@deansheather
Copy link
Member Author

That makes sense. Since this was a intentional design choice I'll close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants