aboutsummaryrefslogtreecommitdiff
path: root/pkg/log
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/log/log.go40
1 files changed, 33 insertions, 7 deletions
diff --git a/pkg/log/log.go b/pkg/log/log.go
index 0238c7e..4c69c1c 100644
--- a/pkg/log/log.go
+++ b/pkg/log/log.go
@@ -7,26 +7,52 @@ import (
)
var debugLogger = log.New(os.Stdout, "", log.LstdFlags)
+var verboseLogger = log.New(os.Stdout, "", log.LstdFlags)
var errorLogger = log.New(os.Stderr, "ERROR ", log.LstdFlags|log.Lmsgprefix)
var warnLogger = log.New(os.Stdout, "WARN ", log.LstdFlags|log.Lmsgprefix)
-var enableDebug = false
-func SetDebug(state bool) {
- enableDebug = state
+type logLevel byte
+
+const (
+ debug logLevel = iota
+ info
+ warn
+)
+
+var level logLevel = warn
+
+func SetVerbose() {
+ level = info
}
-func Print(v ...interface{}) {
- if enableDebug {
+func SetDebug() {
+ level = debug
+}
+
+func Debug(v ...interface{}) {
+ if level <= debug {
_ = debugLogger.Output(2, fmt.Sprint(v...))
}
}
-func Printf(format string, v ...interface{}) {
- if enableDebug {
+func Debugf(format string, v ...interface{}) {
+ if level <= debug {
_ = debugLogger.Output(2, fmt.Sprintf(format, v...))
}
}
+func Print(v ...interface{}) {
+ if level <= info {
+ _ = verboseLogger.Output(2, fmt.Sprint(v...))
+ }
+}
+
+func Printf(format string, v ...interface{}) {
+ if level <= info {
+ _ = verboseLogger.Output(2, fmt.Sprintf(format, v...))
+ }
+}
+
func Error(v ...interface{}) {
_ = errorLogger.Output(2, fmt.Sprint(v...))
}