plugin/errors: remove panic/recover (#1777)

Remove panic/recover and also use pkg/log to print the error. This
brings some consistency into the logging.

Fixes #1776
This commit is contained in:
Miek Gieben
2018-05-10 03:04:46 +01:00
committed by Yong Tang
parent 5e7c399117
commit 874a998697
4 changed files with 16 additions and 76 deletions

View File

@@ -2,8 +2,6 @@ package errors
import (
"fmt"
"log"
"os"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
@@ -24,8 +22,6 @@ func setup(c *caddy.Controller) error {
return plugin.Error("errors", err)
}
handler.Log = log.New(os.Stdout, "", 0)
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
handler.Next = next
return handler
@@ -47,12 +43,10 @@ func errorsParse(c *caddy.Controller) (errorHandler, error) {
args := c.RemainingArgs()
switch len(args) {
case 0:
handler.LogFile = "stdout"
case 1:
if args[0] != "stdout" {
return handler, fmt.Errorf("invalid log file: %s", args[0])
}
handler.LogFile = args[0]
default:
return handler, c.ArgErr()
}