improved logging thing with the "debug" build tag.
This commit is contained in:
24
log_debug.go
Normal file
24
log_debug.go
Normal file
@@ -0,0 +1,24 @@
|
||||
//go:build debug
|
||||
|
||||
package nostr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func debugLog(str string, args ...any) {
|
||||
for i, v := range args {
|
||||
switch v.(type) {
|
||||
case []json.RawMessage:
|
||||
j, _ := json.Marshal(v)
|
||||
args[i] = string(j)
|
||||
case []byte:
|
||||
args[i] = string(v.([]byte))
|
||||
case fmt.Stringer:
|
||||
args[i] = v.(fmt.Stringer).String()
|
||||
}
|
||||
}
|
||||
|
||||
DebugLogger.Printf(str, args...)
|
||||
}
|
||||
Reference in New Issue
Block a user