mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
[plugin/log] Expand {combined} and {common} in log format (#5230)
This PR tries to address the issue raised in 5223 where `{combined}`
or `{common}` in log format will not expand when `{combined}` or `{common}`
is not the only token in the format.
This PR fixes 5223.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@@ -53,15 +53,9 @@ func logParse(c *caddy.Controller) ([]Rule, error) {
|
||||
format := DefaultLogFormat
|
||||
|
||||
if strings.Contains(args[len(args)-1], "{") {
|
||||
switch args[len(args)-1] {
|
||||
case "{common}":
|
||||
format = CommonLogFormat
|
||||
case "{combined}":
|
||||
format = CombinedLogFormat
|
||||
default:
|
||||
format = args[len(args)-1]
|
||||
}
|
||||
|
||||
format = args[len(args)-1]
|
||||
format = strings.Replace(format, "{common}", CommonLogFormat, -1)
|
||||
format = strings.Replace(format, "{combined}", CombinedLogFormat, -1)
|
||||
args = args[:len(args)-1]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user