Tags: go-logr/zapr
Tags
handle panics in logr.Marshaler.MarshalLog The function might panic. The conclusion in go-logr/logr#130 was that the logger should record that. zapr only needs to do that when it calls MarshalLog. Strings and errors are handled by zap. For the sake of simplicity no attempt is made to detect the reason for the panic. In case of a panic, the key is replaced by "<key>Error" and the value with "PANIC=<panic reason>". This is consistent with how zap handles panics.
numeric verbosity and configurable logger behavior This is needed to make zapr usable for Kubernetes. Currently Kubernetes uses a forked zapr with "v" for the numeric verbosity and "err" for Logger.Error. Handling of invalid calls remains compatible with zapr v1.0.0 (= panic log messages are emitted, strongly-type Zap fields are not allowed), but new options allow changing those defaults. Those panic messages now log the source code of the caller, not the zapr.go file where the panic message is logged. The unit tests were derived from https://github.com/kubernetes/kubernetes/blob/cff40a7bcc170c473c223081fd0103fd042dc44b/staging/src/k8s.io/component-base/logs/json/json_test.go and both modified (better error messages, t.Run for each test case) and extended to enhance coverage. Several new edge cases are now covered (for example, error logging at non-zero verbosity levels). New tests for WithName, WithCallDepth and WithValues were added.
PreviousNext