mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-06 22:40:31 -05:00
logging: Better console
encoder defaults (#5109)
This is something that has bothered me for a while, so I figured I'd do something about it now since I'm playing in the logging code lately. The `console` encoder doesn't actually match the defaults that zap's default logger uses. This makes it match better with the rest of the logs when using the `console` encoder alongside somekind of filter, which requires you to configure an encoder to wrap.
This commit is contained in:
parent
2808de1e30
commit
01e192edc9
1 changed files with 24 additions and 19 deletions
|
@ -45,6 +45,12 @@ func (ConsoleEncoder) CaddyModule() caddy.ModuleInfo {
|
||||||
|
|
||||||
// Provision sets up the encoder.
|
// Provision sets up the encoder.
|
||||||
func (ce *ConsoleEncoder) Provision(_ caddy.Context) error {
|
func (ce *ConsoleEncoder) Provision(_ caddy.Context) error {
|
||||||
|
if ce.LevelFormat == "" {
|
||||||
|
ce.LevelFormat = "color"
|
||||||
|
}
|
||||||
|
if ce.TimeFormat == "" {
|
||||||
|
ce.TimeFormat = "wall_milli"
|
||||||
|
}
|
||||||
ce.Encoder = zapcore.NewConsoleEncoder(ce.ZapcoreEncoderConfig())
|
ce.Encoder = zapcore.NewConsoleEncoder(ce.ZapcoreEncoderConfig())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -139,7 +145,6 @@ type LogEncoderConfig struct {
|
||||||
// duration_format <format>
|
// duration_format <format>
|
||||||
// level_format <format>
|
// level_format <format>
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
func (lec *LogEncoderConfig) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
func (lec *LogEncoderConfig) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
for nesting := d.Nesting(); d.NextBlock(nesting); {
|
for nesting := d.Nesting(); d.NextBlock(nesting); {
|
||||||
subdir := d.Val()
|
subdir := d.Val()
|
||||||
|
|
Loading…
Reference in a new issue