Documentation ¶
Overview ¶
Package logging provides functionality to store logrus logging Entry inside a context.Context and then retrieve it from the context.Context.
This package also provides a hook to export logs to signoz via the fluentd protocol.
If you want to set the fields of a logger to be stored in a context so the context and logger can be passed to other functions:
ctx = logging.ToContext(ctx, logrus.Fields{"foo": "bar", "val": 3})
The context returned from ToContext can then be passed to other functions where the logger can be retrieved using WithContext and the logger will be returned with all the fields intact:
logger := logging.FromContext(ctx)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext returns the a logger instance, either a newly initialised logger if one doesn't exist, a fieldless logger if the provided context is nil, or a logger retrieved from the provided context.
The ability to call FromContext with a nil context and get a clean logger instance eliminates the need for a logging.New() constructor.
Types ¶
This section is empty.