From b9c11adf1df27ead5e99bcb7240fb8eaff91d2c3 Mon Sep 17 00:00:00 2001 From: Jayash Satolia Date: Tue, 7 Jan 2025 00:53:31 +0530 Subject: [PATCH] Debug --- core/logger/logger.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/logger/logger.go b/core/logger/logger.go index 4af6e8692..b9e0e1131 100644 --- a/core/logger/logger.go +++ b/core/logger/logger.go @@ -105,8 +105,26 @@ func (l *Logger) Debug(v ...interface{}) { } } +func formatAnyValue(v interface{}) string { + switch v := v.(type) { + case string: + return v + case fmt.Stringer: + return v.String() + case error: + return v.Error() + default: + return fmt.Sprintf("%+v", v) // Default format for all types (including structs) + } +} + func (l *Logger) Info(v ...interface{}) { if l.lvl >= INFO { + // Format each argument to be readable + for i, arg := range v { + v[i] = formatAnyValue(arg) + } + err := l.logInfo.Output(2, fmt.Sprint(v...)) if err != nil { fmt.Printf("Error logging info message: %v", err)