Logging: structured slog messages throughout, and WithLogger options so callers choose the logger
Log messages are lower-case event names with their details as key/value
attributes ("error" for errors), in place of formatted strings.
Loggable package take a WithLogger option as part of their "New*" call,
defaulting to slog.Default(). Each tags its lines with its `component`.
Some debug loggers print directly rather than using slog when in
terminal logging mode.
This commit is contained in:
1 parent
0b5fde9563
commit
043e307663
49 files changed
+598
-248
No files matched your search
@@ -65,7 +65,7 @@ func (o *Options) RunSetup(
|
||||
// Check if the logging should be switched to file
|
||||
if !terminalLog {
|
||||
if len(conf.Logging.File) == 0 {
|
||||
slog.Warn("No log file configured, remaining in console logging mode!")
|
||||
slog.Warn("no log file configured; logging to the terminal")
|
||||
} else if err := logging.LogToFile(conf.Logging.File); err != nil {
|
||||
return nil, fmt.Errorf("opening log file: %w", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user