Skip to content

Commit

Permalink
feat: add Debug method for conditional logging in handlers
Browse files Browse the repository at this point in the history
- Introduced a new Debug method in the Handlers struct to enable debug logging based on the web server's debug mode setting.
- Enhanced logging capabilities to provide detailed output when debug mode is enabled, improving traceability and debugging efficiency.
  • Loading branch information
tphakala committed Jan 8, 2025
1 parent 88cffd5 commit 37bcf4e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/httpcontroller/handlers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package handlers

import (
"log"
"strconv"
"time"

Expand Down Expand Up @@ -62,3 +63,14 @@ func parseOffset(offsetStr string, defaultOffset int) int {
}
return offset
}

// Debug logs debug messages if debug mode is enabled
func (h *Handlers) Debug(format string, v ...interface{}) {
if h.Settings.WebServer.Debug {
if len(v) == 0 {
log.Print(format)
} else {
log.Printf(format, v...)
}
}
}

0 comments on commit 37bcf4e

Please sign in to comment.