2025-08-11 01:16:52 +02:00
|
|
|
package main
|
|
|
|
|
2025-08-15 03:38:24 +02:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
func dump(name string, val any) {
|
2025-08-16 15:15:06 +02:00
|
|
|
if !env.Debug {
|
2025-08-15 03:38:24 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
b, _ := json.MarshalIndent(val, "", "\t")
|
|
|
|
os.WriteFile(name, b, 0644)
|
|
|
|
}
|
|
|
|
|
2025-08-14 17:08:45 +02:00
|
|
|
func debug(format string, args ...any) {
|
2025-08-16 15:15:06 +02:00
|
|
|
if !env.Debug {
|
2025-08-11 01:16:52 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-08-14 17:08:45 +02:00
|
|
|
log.Debugf(format+"\n", args...)
|
2025-08-11 01:16:52 +02:00
|
|
|
}
|
|
|
|
|
2025-08-14 17:08:45 +02:00
|
|
|
func debugIf(cond bool, format string, args ...any) {
|
|
|
|
if !cond {
|
2025-08-11 01:16:52 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2025-08-14 17:08:45 +02:00
|
|
|
debug(format, args)
|
2025-08-11 01:16:52 +02:00
|
|
|
}
|