plugin/log: remove need to specify stdout (#1221)

* plugin/log: remove need to specify stdout

Since log will only be output to stdout is doesn't make sense to
specify it in Corefile.

Fixes: #1218

* fixup! plugin/log: remove need to specify stdout
This commit is contained in:
Christian Nilsson
2017-11-13 10:23:27 +01:00
committed by Miek Gieben
parent 9b8ee1c119
commit 46a187df8f
4 changed files with 29 additions and 52 deletions

View File

@@ -1,7 +1,6 @@
package log
import (
"fmt"
"log"
"os"
@@ -55,32 +54,21 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
Format: DefaultLogFormat,
})
} else if len(args) == 1 {
// Only an output file specified, can only be *stdout*
if args[0] != "stdout" {
return nil, fmt.Errorf("only stdout is allowed: %s", args[0])
}
rules = append(rules, Rule{
NameScope: ".",
NameScope: dns.Fqdn(args[0]),
Format: DefaultLogFormat,
})
} else {
// Name scope, output file (stdout), and maybe a format specified
// Name scope, and maybe a format specified
format := DefaultLogFormat
if len(args) > 2 {
switch args[2] {
case "{common}":
format = CommonLogFormat
case "{combined}":
format = CombinedLogFormat
default:
format = args[2]
}
}
if args[1] != "stdout" {
return nil, fmt.Errorf("only stdout is allowed: %s", args[1])
switch args[1] {
case "{common}":
format = CommonLogFormat
case "{combined}":
format = CombinedLogFormat
default:
format = args[1]
}
rules = append(rules, Rule{