aboutsummaryrefslogtreecommitdiff
path: root/plugin.md
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-04-18 21:02:01 +0100
committerGravatar GitHub <noreply@github.com> 2018-04-18 21:02:01 +0100
commitb4b65fbc188551d7fd6222026f57c0efb7d53855 (patch)
tree9e2322d2e577d137c406de319f65f9dff850db47 /plugin.md
parent51e1442bd97f6d51eccb5b18e36cfffd8e61bc1e (diff)
downloadcoredns-b4b65fbc188551d7fd6222026f57c0efb7d53855.tar.gz
coredns-b4b65fbc188551d7fd6222026f57c0efb7d53855.tar.zst
coredns-b4b65fbc188551d7fd6222026f57c0efb7d53855.zip
pkg/log: ability for debug logs (#1689)
* pkg/log: ability for debug logs When the debug plugin is enabled all log.Debug calls will print to standard; if not there are a noop (almost). The log package wraps some standard log functions as well, so just replacing "log" with "plugin/pkg/log" should be enough to use this package. * docs * Add docs * lint * Test fallthrough to log pkg as well * simple package - up test coverage * add other log levels as well * update docs
Diffstat (limited to 'plugin.md')
-rw-r--r--plugin.md12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugin.md b/plugin.md
index 3e0bb86e9..e94de6d1c 100644
--- a/plugin.md
+++ b/plugin.md
@@ -35,11 +35,15 @@ See a couple of blog posts on how to write and add plugin to CoreDNS:
## Logging
-If your plugin needs to output a log line you should use the `log` package. CoreDNS does not
-implement log levels. The standard way of outputing is: `log.Printf("[LEVEL] ...")`, and LEVEL
-can be: `INFO`, `WARNING` or `ERROR`.
+If your plugin needs to output a log line you should use the `plugin/pkg/log` package. This package
+implements log levels. The standard way of outputting is: `log.Info` for info level messages. The
+levels available are `log.Info`, `log.Warning`, `log.Error`, `log.Debug`. Each of these also has
+a `f` variant.
+
In general, logging should be left to the higher layers by returning an error. However, if there is
-a reason to consume the error but notify the user, then logging in the plugin can be acceptable.
+a reason to consume the error and notify the user, then logging in the plugin itself can be
+acceptable. The `Debug*` functions only output something when the *debug* plugin is loaded in the
+server.
## Metrics