Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: structured error, funcr.PseudoStruct #361

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Commits on Dec 6, 2022

  1. support funcr/types.PseudoStruct

    This special type can be used in WithValues/Info/Error or as result
    of MarshalLog. It gets rendered like a struct, with curly brackets
    around the content.
    pohly committed Dec 6, 2022
    Configuration menu
    Copy the full SHA
    7daf06d View commit details
    Browse the repository at this point in the history
  2. support "structured error"

    A "structured error" is an error type that implements both Error and
    MarshalLog. It gets logged like a normal error with "err=<Error()>", but then
    another "errDetails=<MarshalLog()>" gets added to log additional information
    that may be stored in the error.
    
    The result of MarshalLog is logged like any other value. Beware that rendering
    of structs, in particular multi-line strings in structs, is not very readable
    because it all gets handled by `fmt.Sprintf`. To get nicer output of multiple
    values, a logr.KeysAndValues can be returned. Those values than are formatted
    one-by-one by klog, which means that multi-line strings are readable.
    pohly committed Dec 6, 2022
    Configuration menu
    Copy the full SHA
    2ca1701 View commit details
    Browse the repository at this point in the history