From ab033f85dfd715ea90a4656f0379344be935534d Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 7 Aug 2020 09:13:53 +0200 Subject: [PATCH] util: add FatalLog(), ErrorLog() and WarningLog() functions These functions will always log the message, irrespectively of the log-level that has been configured. Signed-off-by: Niels de Vos --- internal/util/log.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/util/log.go b/internal/util/log.go index 7ce064189..97b79a0d2 100644 --- a/internal/util/log.go +++ b/internal/util/log.go @@ -52,6 +52,24 @@ func Log(ctx context.Context, format string) string { return a + format } +// FatalLog helps in logging fatal errors. +func FatalLog(message string, args ...interface{}) { + logMessage := fmt.Sprintf(message, args...) + klog.FatalDepth(1, logMessage) +} + +// ErrorLog helps in logging errors. +func ErrorLog(message string, args ...interface{}) { + logMessage := fmt.Sprintf(message, args...) + klog.ErrorDepth(1, logMessage) +} + +// WarningLog helps in logging warnings. +func WarningLog(message string, args ...interface{}) { + logMessage := fmt.Sprintf(message, args...) + klog.WarningDepth(1, logMessage) +} + // DefaultLog helps in logging with klog.level 1. func DefaultLog(message string, args ...interface{}) { logMessage := fmt.Sprintf(message, args...)