improved logging thing with the "debug" build tag.

This commit is contained in:
fiatjaf
2023-04-11 09:07:37 -03:00
parent 7b0af23f1a
commit 6f74d284c4
6 changed files with 51 additions and 20 deletions

24
log_debug.go Normal file
View 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...)
}