Files
qzmq/logging_simple.go
zeekayandHanzo Dev bfe4d9b5cb Go 1.27.1, and the code it can say more simply
Modules declare go 1.27.1 and the build images follow. go fix applied the
modernizers: any, atomic types, strings.Builder, range over int, and the
last // +build line is gone. omitzero is not applied, since it changes what
the JSON says.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-16 19:15:01 -07:00

66 lines
1.2 KiB
Go

package qzmq
import (
"fmt"
"log"
"strings"
)
// Simple logging functions using standard log package
func logDebug(msg string, args ...any) {
if len(args) > 0 {
log.Printf("[DEBUG] %s %v", msg, args)
} else {
log.Printf("[DEBUG] %s", msg)
}
}
func logInfo(msg string, args ...any) {
if len(args) > 0 {
log.Printf("[INFO] %s %v", msg, args)
} else {
log.Printf("[INFO] %s", msg)
}
}
func logWarn(msg string, args ...any) {
if len(args) > 0 {
log.Printf("[WARN] %s %v", msg, args)
} else {
log.Printf("[WARN] %s", msg)
}
}
func logError(msg string, args ...any) {
if len(args) > 0 {
log.Printf("[ERROR] %s %v", msg, args)
} else {
log.Printf("[ERROR] %s", msg)
}
}
func logFatal(msg string, args ...any) {
if len(args) > 0 {
log.Fatalf("[FATAL] %s %v", msg, args)
} else {
log.Fatalf("[FATAL] %s", msg)
}
}
// formatFields formats key-value pairs for logging
func formatFields(args []any) string {
if len(args) == 0 {
return ""
}
var result strings.Builder
for i := 0; i < len(args)-1; i += 2 {
if i > 0 {
result.WriteString(", ")
}
result.WriteString(fmt.Sprintf("%v=%v", args[i], args[i+1]))
}
return result.String()
}