Skip to content

Commit

Permalink
[MFW-5800] Remove false WARN at logger start (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
kskrzypczyn-arista authored Nov 22, 2024
1 parent 927b197 commit 9f99a11
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions services/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Logger struct {
isLogCountEnabled bool
}

// This is only used inernally.
// This is only used internally.
// This was originally stored in every Logger structure which seems wasteful
var logLevelName = [...]string{"EMERG", "ALERT", "CRIT", "ERROR", "WARN", "NOTICE", "INFO", "DEBUG", "TRACE"}

Expand Down Expand Up @@ -101,10 +101,13 @@ func GetLoggerInstance() *Logger {
// has fallback mechanisms.
if err != nil {
loggerSingleton.Err("Error initializing settings file: %v \n", err)
} else {
// Load the config to set the logLevelMap from the settings file.
loggerSingleton.LoadConfig(loggerSingleton.config)
}
// calling LoadConfig un else would cause it to fail in GetLogLevelMapFromSettingsFile
// as DefaultLoggerConfig sets SettingsPath to an empty slice,
// DefaultLoggerConfig sets LogLevelHighest and logLevelMap
// so we can just skip the call to LoadConfig
// if anyone wants to add LoadConfig call here make sure not to
// introduce false warning from SettingsPath being an empty slice
})

return loggerSingleton
Expand Down Expand Up @@ -423,7 +426,7 @@ func (logger *Logger) getLogLevel(packageName string, functionName string) int32
return LogLevelInfo
}

// logFormatter creats a log message using the format and arguments provided
// logFormatter creates a log message using the format and arguments provided
// We look for and handle special format verbs that trigger additional processing
func logFormatter(format string, newOcname Ocname, args ...interface{}) string {

Expand Down Expand Up @@ -457,7 +460,7 @@ func (logger *Logger) isLogEnabled(level int32) bool {
// logMessage is called to write messages to the system log
func (logger *Logger) logMessage(level int32, format string, newOcname Ocname, args ...interface{}) {
// logger.config.LogLevelMask keeps track of the logger levels that have been
// requested across the entire logger confguration so that we can drop out of this
// requested across the entire logger configuration so that we can drop out of this
// function quickly if the log is for something unlikely like a trace or debug.
if level > logger.getLogLevelHighest() {
return
Expand Down Expand Up @@ -517,7 +520,7 @@ func (logger *Logger) logMessage(level int32, format string, newOcname Ocname, a
// packageName Name like "dict"
// functionName Package path from package name to calling function.
//
// This is meant to be an explict path so you can match very granular on a specific function.
// This is meant to be an explicit path so you can match very granular on a specific function.
// This can be:
// dict.cleanDictionary
// plugins.(*PluginControl).Startup
Expand Down Expand Up @@ -606,7 +609,7 @@ func (logger *Logger) startRefreshConfigOnSIGHUP() {
for {
sig := <-hupch

logger.Info("Received signal [%v]. Refreshing loggger config\n", sig)
logger.Info("Received signal [%v]. Refreshing logger config\n", sig)
logger.LoadConfig(logger.config)
}

Expand Down

0 comments on commit 9f99a11

Please sign in to comment.