crzerolog icon indicating copy to clipboard operation
crzerolog copied to clipboard

handler breaks zerolog.ConsoleWriter

Open ernest-ag5 opened this issue 1 year ago • 3 comments

hi,

for local development, we setup the zerolog logger with a ConsoleWriter.

However, since the crzerolog handler is removing the "level" field, replacing? it with "severity", the console writer cannot see the log level producing output such as

1:51PM ??? call the starters count=0
1:51PM ??? services are ready for business

ernest-ag5 avatar Sep 07 '22 12:09 ernest-ag5

maybe the Console write should respect zerolog.LevelFieldName

ernest-ag5 avatar Sep 07 '22 14:09 ernest-ag5

my workaround is to override the FormalLevel as the crzerolog pkg changes the labels for the levels.

cons := zerolog.ConsoleWriter{Out: os.Stderr}
cons.FormatLevel = func(i interface{}) string {
	if s, ok := i.(string); ok {
		return s
	}
	return "<?>"
}

ernest-ag5 avatar Sep 09 '22 14:09 ernest-ag5

Thanks @ernest-ag5. This package renames the level value and that causes ??? in zerolog ConsoleWriter logic.

I filed a PR in zerolog to fix this issue: https://github.com/rs/zerolog/pull/476

For the time being, please use the workaround you mentioned.

yfuruyama avatar Sep 11 '22 03:09 yfuruyama

This issue was fixed in https://github.com/yfuruyama/crzerolog/pull/4, please use the latest version of this package.

yfuruyama avatar Sep 19 '22 00:09 yfuruyama

please create a new tag so I can update my deps

ernest-ag5 avatar Sep 19 '22 06:09 ernest-ag5

@ernest-ag5 Tagged: https://github.com/yfuruyama/crzerolog/releases/tag/v0.3.1

Thanks!

yfuruyama avatar Sep 19 '22 07:09 yfuruyama