util: add ErrorLog for log with context

added a new function ErrorLog to log with
context.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2020-08-11 16:43:50 +05:30 committed by mergify[bot]
parent 9229e84a77
commit 7c24f4d597

View File

@ -64,6 +64,12 @@ func ErrorLogMsg(message string, args ...interface{}) {
klog.ErrorDepth(1, logMessage) 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. // WarningLog helps in logging warnings.
func WarningLog(message string, args ...interface{}) { func WarningLog(message string, args ...interface{}) {
logMessage := fmt.Sprintf(message, args...) logMessage := fmt.Sprintf(message, args...)