first commit
This commit is contained in:
29
pkg/middleware/log_flags.go
Normal file
29
pkg/middleware/log_flags.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func envBool(key string, fallback bool) bool {
|
||||
raw := strings.TrimSpace(strings.ToLower(os.Getenv(key)))
|
||||
if raw == "" {
|
||||
return fallback
|
||||
}
|
||||
switch raw {
|
||||
case "1", "true", "yes", "on":
|
||||
return true
|
||||
case "0", "false", "no", "off":
|
||||
return false
|
||||
default:
|
||||
return fallback
|
||||
}
|
||||
}
|
||||
|
||||
func policyLogf(enabled bool, format string, args ...any) {
|
||||
if !enabled {
|
||||
return
|
||||
}
|
||||
log.Printf(format, args...)
|
||||
}
|
||||
Reference in New Issue
Block a user