File: debug.go

package info (click to toggle)
pat 0.19.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,296 kB
  • sloc: javascript: 3,891; sh: 124; makefile: 11
file content (27 lines) | stat: -rw-r--r-- 340 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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...)
}