Merge pull request #1255 from jkroepke/fix-eventlog

Fix panic with log.file=eventlog
This commit is contained in:
Ben Reedy 2023-07-22 08:31:11 +10:00 committed by GitHub
commit 9a2ec21278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -24,6 +24,7 @@ func (f *AllowedFile) String() string {
// Set updates the value of the allowed format. // Set updates the value of the allowed format.
func (f *AllowedFile) Set(s string) error { func (f *AllowedFile) Set(s string) error {
f.s = s
switch s { switch s {
case "stdout": case "stdout":
f.w = os.Stdout f.w = os.Stdout
@ -77,6 +78,8 @@ func New(config *Config) (log.Logger, error) {
return nil, err return nil, err
} }
l = eventlog.NewEventLogLogger(w, loggerFunc) l = eventlog.NewEventLogLogger(w, loggerFunc)
} else if config.File.w == nil {
panic("logger: file writer is nil")
} else { } else {
l = loggerFunc(log.NewSyncWriter(config.File.w)) l = loggerFunc(log.NewSyncWriter(config.File.w))
} }