Skip to content

Commit b44f82d

Browse files
committed
Refine logging configuration in Config struct
Simplify and clarify the behavior of `Logger` and `LogOutput` fields in the Config struct. Updated related comments and removed redundant logic for improved readability and maintainability.
1 parent 6991973 commit b44f82d

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

config/config.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,13 @@ type Config struct {
260260
// Default hasher is github.com/cespare/xxhash/v2
261261
Hasher hasher.Hasher
262262

263-
// LogOutput is the writer where logs should be sent. If this is not
264-
// set, logging will go to stderr by default. You cannot specify both LogOutput
265-
// and Logger at the same time.
263+
// LogOutput is the writer where logs should be sent when no custom logger
264+
// is provided. If unset, stderr is used by default.
265+
// If Logger is set, LogOutput is ignored.
266266
LogOutput io.Writer
267267

268-
// Logger is a custom logger which you provide. If Logger is set, it will use
269-
// this for the internal logger. If Logger is not set, it will fall back to the
270-
// behavior for using LogOutput. You cannot specify both LogOutput and Logger
271-
// at the same time.
268+
// Logger is a user-provided custom logger. When this is set, Olric will use
269+
// it as-is and will not inspect or modify LogOutput.
272270
Logger *log.Logger
273271

274272
// DMaps denotes a global configuration for DMaps. You can still overwrite it
@@ -406,8 +404,6 @@ func (c *Config) Sanitize() error {
406404

407405
if c.Logger == nil {
408406
c.Logger = log.New(c.LogOutput, "", log.LstdFlags)
409-
} else {
410-
c.Logger.SetOutput(c.LogOutput)
411407
}
412408

413409
if c.Hasher == nil {

0 commit comments

Comments
 (0)