From 7c24f4d59717816d035b2479c5d67995303e27b4 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Tue, 11 Aug 2020 16:43:50 +0530 Subject: [PATCH] util: add ErrorLog for log with context added a new function ErrorLog to log with context. Signed-off-by: Madhu Rajanna --- internal/util/log.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/util/log.go b/internal/util/log.go index 4b5e28be3..d630ceff9 100644 --- a/internal/util/log.go +++ b/internal/util/log.go @@ -64,6 +64,12 @@ func ErrorLogMsg(message string, args ...interface{}) { klog.ErrorDepth(1, logMessage) } +// ErrorLog helps in logging errors with context. +func ErrorLog(ctx context.Context, message string, args ...interface{}) { + logMessage := fmt.Sprintf(Log(ctx, message), args...) + klog.ErrorDepth(1, logMessage) +} + // WarningLog helps in logging warnings. func WarningLog(message string, args ...interface{}) { logMessage := fmt.Sprintf(message, args...)