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 <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-08-07 09:13:53 +02:00 committed by mergify[bot]
parent 44863a9d29
commit ab033f85df

View File

@ -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...)