Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Jan 6, 2025
1 parent 5282742 commit b9c11ad
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b9c11ad

Please sign in to comment.