Skip to content

Commit

Permalink
home: log conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Aug 11, 2023
1 parent 418c830 commit 67c7767
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/home/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ func readLogSettings() (ls *logSettings) {

yamlFile, err := readConfigFile()
if err != nil {
return &logSettings{}
return nil
}

err = yaml.Unmarshal(yamlFile, conf)
Expand Down
19 changes: 8 additions & 11 deletions internal/home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,22 +794,19 @@ func configureLogger(opts options) (err error) {

// getLogSettings returns a log settings object properly initialized from opts.
func getLogSettings(opts options) (ls *logSettings) {
ls = readLogSettings()
configLogSettings := config.Log

ls = readLogSettings()
if ls == nil {
// Use default log settings.
ls = &configLogSettings
}

// Command-line arguments can override config settings.
if opts.verbose || configLogSettings.Verbose {
if opts.verbose {
ls.Verbose = true
}

ls.File = stringutil.Coalesce(opts.logFile, configLogSettings.File, ls.File)

// Handle default log settings overrides.
ls.Compress = configLogSettings.Compress
ls.LocalTime = configLogSettings.LocalTime
ls.MaxBackups = configLogSettings.MaxBackups
ls.MaxSize = configLogSettings.MaxSize
ls.MaxAge = configLogSettings.MaxAge
ls.File = stringutil.Coalesce(opts.logFile, ls.File)

if opts.runningAsService && ls.File == "" && runtime.GOOS == "windows" {
// When running as a Windows service, use eventlog by default if
Expand Down

0 comments on commit 67c7767

Please sign in to comment.