From 1be345b07f8fa393a3c88d7e65bda657463cdf02 Mon Sep 17 00:00:00 2001 From: Dominik Polakovics Date: Sat, 1 Mar 2025 05:24:18 +0100 Subject: [PATCH] Add standard and structured logging methods to enhance logging capabilities --- internal/logger/logger.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index d650f75..f26c161 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -33,6 +33,11 @@ func Init(level string, filePath string) error { return nil } +// Standard logging methods +func Debug(args ...interface{}) { + log.Debug(args...) +} + func Info(args ...interface{}) { log.Info(args...) } @@ -41,14 +46,11 @@ func Error(args ...interface{}) { log.Error(args...) } -func Debug(args ...interface{}) { - log.Debug(args...) -} - func Warn(args ...interface{}) { log.Warn(args...) } +// Structured logging methods func WithField(key string, value interface{}) *logrus.Entry { return log.WithField(key, value) } @@ -56,3 +58,7 @@ func WithField(key string, value interface{}) *logrus.Entry { func WithFields(fields logrus.Fields) *logrus.Entry { return log.WithFields(fields) } + +func WithError(err error) *logrus.Entry { + return log.WithError(err) +}