aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-07-20 19:45:17 +0100
committerGravatar GitHub <noreply@github.com> 2018-07-20 19:45:17 +0100
commit84ec780ffcf7f4712184803c5ede2473957f0b66 (patch)
treef985e6da00800c03862feb3cae7279ab497ad01e /plugin/pkg
parent547f15546563c9d8bb520218cd3c9161394d9d20 (diff)
downloadcoredns-84ec780ffcf7f4712184803c5ede2473957f0b66.tar.gz
coredns-84ec780ffcf7f4712184803c5ede2473957f0b66.tar.zst
coredns-84ec780ffcf7f4712184803c5ede2473957f0b66.zip
New plugin: loop (#1989)
* New plugin: loop Add a plugin that detects loops. It does this by sending an unique query to our selves. If we see the query more than twice we stop the process. If there isn't a loop, the plugin disables it self and becomes a noop plugin. Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/pkg')
-rw-r--r--plugin/pkg/log/plugin.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugin/pkg/log/plugin.go b/plugin/pkg/log/plugin.go
index 354c19d3f..1df302609 100644
--- a/plugin/pkg/log/plugin.go
+++ b/plugin/pkg/log/plugin.go
@@ -3,6 +3,7 @@ package log
import (
"fmt"
golog "log"
+ "os"
)
// P is a logger that includes the plugin doing the logging.
@@ -58,4 +59,10 @@ func (p P) Error(v ...interface{}) { p.log(err, v...) }
// Errorf logs as log.Errorf.
func (p P) Errorf(format string, v ...interface{}) { p.logf(err, format, v...) }
+// Fatal logs as log.Fatal and calls os.Exit(1).
+func (p P) Fatal(v ...interface{}) { p.log(fatal, v...); os.Exit(1) }
+
+// Fatalf logs as log.Fatalf and calls os.Exit(1).
+func (p P) Fatalf(format string, v ...interface{}) { p.logf(fatal, format, v...); os.Exit(1) }
+
func pFormat(s string) string { return "plugin/" + s + ": " }