Skip to content

Commit

Permalink
Implement ConsoleOut in Windows logger (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa authored Mar 5, 2024
1 parent 3ec9abf commit f7608c2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion logging/logger_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type LoggerConfig struct {
Compress bool
LocalTime bool

// the output of config.Console log will be written to this writer, if it is nil os.Stdout will be used.
ConsoleOut io.Writer

// group name
Name string
}
Expand All @@ -44,8 +47,13 @@ func NewLogger(ctx context.Context, cfg LoggerConfig) zerolog.Logger {
_, span := otel.Tracer(config.TracerName).Start(ctx, "Create new logger")

// Create a new logger.
var consoleOut io.Writer = os.Stdout
if cfg.ConsoleOut != nil {
consoleOut = cfg.ConsoleOut
}

consoleWriter := zerolog.ConsoleWriter{
Out: os.Stdout,
Out: consoleOut,
TimeFormat: cfg.ConsoleTimeFormat,
NoColor: cfg.NoColor,
}
Expand Down

0 comments on commit f7608c2

Please sign in to comment.