diff --git a/health/check.go b/health/check.go index f9029a9..a770ae6 100644 --- a/health/check.go +++ b/health/check.go @@ -2,6 +2,7 @@ package health import ( "context" + "flag" "fmt" "io" "net/http" @@ -66,3 +67,14 @@ func CheckStatus(servicePath string, timeout time.Duration) int { return 0 } + +// RunningHealthCheck returns whether the -check flag was used when starting the program. +// This flag indicates that the program is being used to run a health check on another program. +func RunningHealthCheck() bool { + + var isHealthCheck bool + flag.BoolVar(&isHealthCheck, "check", false, "Whether the program is being used to run a health check") + flag.Parse() + + return isHealthCheck +} diff --git a/slogger/logger.go b/slogger/logger.go index 653cf34..5f45a8f 100644 --- a/slogger/logger.go +++ b/slogger/logger.go @@ -46,8 +46,8 @@ func (sl *SmartLogger) Log(message ...any) int { if repeated && now.Sub(sl.lastLogTime) <= sl.window { sl.repeatCount++ } else { - log.Println(msgString) if sl.repeatedPrefix != "" && !repeated { //this is a random message + log.Println(msgString) sl.lastMessage = "" // Reset lastMessage to avoid tracking it as a repeated message sl.lastLogTime = time.Time{} // Reset the time return 0