mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
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:
committed by
Miek Gieben
parent
9b8ee1c119
commit
46a187df8f
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user