aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/pkg/log/log.go19
-rw-r--r--plugin/pkg/log/log_test.go7
2 files changed, 20 insertions, 6 deletions
diff --git a/plugin/pkg/log/log.go b/plugin/pkg/log/log.go
index 2d8ba78d8..6f9dd07c6 100644
--- a/plugin/pkg/log/log.go
+++ b/plugin/pkg/log/log.go
@@ -1,7 +1,7 @@
-// Package log implements a small wrapper around the std lib log package.
-// It implements log levels by prefixing the logs with the current time
-// with in RFC3339Milli and [INFO], [DEBUG], [WARNING] or [ERROR].
-// Debug logging is available and enabled if the *debug* plugin is used.
+// Package log implements a small wrapper around the std lib log package. It
+// implements log levels by prefixing the logs with [INFO], [DEBUG], [WARNING]
+// or [ERROR]. Debug logging is available and enabled if the *debug* plugin is
+// used.
//
// log.Info("this is some logging"), will log on the Info level.
//
@@ -25,14 +25,21 @@ type d struct {
sync.RWMutex
}
-// Set sets d to true.
+// Set enables debug logging.
func (d *d) Set() {
d.Lock()
d.on = true
d.Unlock()
}
-// Value return the boolean value of d.
+// Clear disables debug logging.
+func (d *d) Clear() {
+ d.Lock()
+ d.on = false
+ d.Unlock()
+}
+
+// Value returns if debug logging is enabled.
func (d *d) Value() bool {
d.RLock()
b := d.on
diff --git a/plugin/pkg/log/log_test.go b/plugin/pkg/log/log_test.go
index 4f0dc4f43..32c1d39ad 100644
--- a/plugin/pkg/log/log_test.go
+++ b/plugin/pkg/log/log_test.go
@@ -23,6 +23,13 @@ func TestDebug(t *testing.T) {
if x := f.String(); !strings.Contains(x, debug+"debug") {
t.Errorf("Expected debug log to be %s, got %s", debug+"debug", x)
}
+ f.Reset()
+
+ D.Clear()
+ Debug("debug")
+ if x := f.String(); x != "" {
+ t.Errorf("Expected no debug logs, got %s", x)
+ }
}
func TestDebugx(t *testing.T) {