coder/slog

Configurable human logger

Closed this issue · 4 comments

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 {}

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.

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.

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.

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