pat/internal/debug/debug.go
Martin Hebnes Pedersen 5ff709abe2 Refactor insertion tags and use for all templates
Also make the search case-insentitive since caseness is not strictly
handled in HTML forms. Unsupported insertion tags are logged (debug).
2024-01-20 18:38:09 +00:00

27 lines
340 B
Go

package debug
import (
"log"
"os"
"strconv"
)
const (
EnvVar = "PAT_DEBUG"
Prefix = "[DEBUG] "
)
var enabled bool
func init() {
enabled, _ = strconv.ParseBool(os.Getenv(EnvVar))
}
func Enabled() bool { return enabled }
func Printf(format string, v ...interface{}) {
if !enabled {
return
}
log.Printf(Prefix+format, v...)
}