You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This outputs the default string representation which currently looks like this:
[1] some-component "some event" x=123 y=42
The genericr.Entry struct you receive in your handler contains the following fields
that you can use to do your own formatting:
typeEntrystruct {
Levelint// level at which this was loggedNamestring// name parts joined with '.'NameParts []string// individual name segmentsMessagestring// message as send to log callErrorerror// error if .Error() was calledFields []interface{} // alternating key-value pairs// Caller informationCaller runtime.Frame// only available after .WithCaller(true)CallerDepthint// caller depth from callback
}
Use e.FieldsMap() to retrieve the Fields as a map.
To enable caller information, use genericr.New(...).WithCaller(true).
To filter messages above a certain verbosity level, use genericr.New(...).WithVerbosity(1).
Usage in tests
This shows how you can redirect logs to the testing.T logger and keep a reference
to the last log entry if you want to check that one: