mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/log: remove OutputFile (#1217)
* plugin/log: remove OutputFile We use stdout for everything, remove OutputFile as it isn't used and causes confusion. Fixes #1216 * PR feedback
This commit is contained in:
@@ -29,13 +29,7 @@ func setup(c *caddy.Controller) error {
|
||||
// Open the log files for writing when the server starts
|
||||
c.OnStartup(func() error {
|
||||
for i := 0; i < len(rules); i++ {
|
||||
// We only support stdout
|
||||
writer := os.Stdout
|
||||
if rules[i].OutputFile != "stdout" {
|
||||
return plugin.Error("log", fmt.Errorf("invalid log file: %s", rules[i].OutputFile))
|
||||
}
|
||||
|
||||
rules[i].Log = log.New(writer, "", 0)
|
||||
rules[i].Log = log.New(os.Stdout, "", 0)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -57,19 +51,20 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
|
||||
if len(args) == 0 {
|
||||
// Nothing specified; use defaults
|
||||
rules = append(rules, Rule{
|
||||
NameScope: ".",
|
||||
OutputFile: DefaultLogFilename,
|
||||
Format: DefaultLogFormat,
|
||||
NameScope: ".",
|
||||
Format: DefaultLogFormat,
|
||||
})
|
||||
} else if len(args) == 1 {
|
||||
// Only an output file specified.
|
||||
// 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: ".",
|
||||
OutputFile: args[0],
|
||||
Format: DefaultLogFormat,
|
||||
NameScope: ".",
|
||||
Format: DefaultLogFormat,
|
||||
})
|
||||
} else {
|
||||
// Name scope, output file, and maybe a format specified
|
||||
// Name scope, output file (stdout), and maybe a format specified
|
||||
|
||||
format := DefaultLogFormat
|
||||
|
||||
@@ -84,10 +79,13 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if args[1] != "stdout" {
|
||||
return nil, fmt.Errorf("only stdout is allowed: %s", args[1])
|
||||
}
|
||||
|
||||
rules = append(rules, Rule{
|
||||
NameScope: dns.Fqdn(args[0]),
|
||||
OutputFile: args[1],
|
||||
Format: format,
|
||||
NameScope: dns.Fqdn(args[0]),
|
||||
Format: format,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user