Documentation ¶
Index ¶
- Constants
- func GetWriter(f Format) io.Writer
- type CtxHook
- type CtxHookFunc
- type CtxLogger
- func (l CtxLogger) Component() string
- func (l CtxLogger) CtxHook(h ...CtxHook) CtxLogger
- func (l CtxLogger) Debug(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Err(ctx context.Context, err error) *zerolog.Event
- func (l CtxLogger) Error(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Fatal(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Info(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Log(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Panic(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Trace(ctx context.Context) *zerolog.Event
- func (l CtxLogger) Warn(ctx context.Context) *zerolog.Event
- func (l CtxLogger) WithComponent(component string) CtxLogger
- func (l CtxLogger) WithLevel(ctx context.Context, level zerolog.Level) *zerolog.Event
- func (l CtxLogger) ZerologWithComponent() zerolog.Logger
- type Format
Constants ¶
const ( ComponentField = "component" ConnectorIDField = "connector_id" DurationField = "duration" MessageIDField = "message_id" NodeIDField = "node_id" PipelineIDField = "pipeline_id" RecordPositionField = "record_position" RequestIDField = "request_id" ServerAddressField = "address" GRPCMethodField = "grpc_method" GRPCStatusCodeField = "grpc_status_code" HTTPEndpointField = "http_endpoint" PluginTypeField = "plugin_type" PluginNameField = "plugin_name" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CtxHook ¶
type CtxHook interface { // Run runs the hook with the logger context. Run(ctx context.Context, e *zerolog.Event, l zerolog.Level) }
CtxHook defines an interface for a log context hook.
type CtxHookFunc ¶
CtxHookFunc is an adaptor to allow the use of an ordinary function as a Hook.
type CtxLogger ¶
CtxLogger is a wrapper around a zerolog.Logger which adds support for adding context hooks to it. All methods that return *zerolog.Event are switched for versions that take a context and trigger context hooks before returning the entry.
func InitLogger ¶ added in v0.2.0
InitLogger returns a logger initialized with the wanted level and format
func (CtxLogger) Debug ¶
Debug starts a new message with debug level and context ctx.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Err ¶
Err starts a new message with context ctx and error level with err as a field if not nil or with info level if err is nil.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Error ¶
Error starts a new message with error level and context ctx.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Fatal ¶
Fatal starts a new message with fatal level and context ctx. The os.Exit(1) function is called by the Msg method, which terminates the program immediately.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Info ¶
Info starts a new message with info level and context ctx.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Log ¶
Log starts a new message with no level and context ctx. Setting GlobalLevel to Disabled will still disable events produced by this method.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Panic ¶
Panic starts a new message with panic level and context ctx. The panic() function is called by the Msg method, which stops the ordinary flow of a goroutine.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Trace ¶
Trace starts a new message with trace level and context ctx.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) Warn ¶
Warn starts a new message with warn level and context ctx.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) WithComponent ¶
WithComponent adds the component to the output. This function can be called multiple times with the same value and it will produce the same result. If component is an empty string then nothing will be added to the output.
func (CtxLogger) WithLevel ¶
WithLevel starts a new message with level and context ctx. Unlike Fatal and Panic methods, WithLevel does not terminate the program or stop the ordinary flow of a gourotine when used with their respective levels.
You must call Msg on the returned event in order to send the event.
func (CtxLogger) ZerologWithComponent ¶ added in v0.2.0
ZerologWithComponent returns a zerolog.Logger that adds the component field to all log entries.
type Format ¶ added in v0.2.0
type Format int
func ParseFormat ¶ added in v0.2.0
ParseFormat converts a format string into a log Format value. returns an error if the input string does not match known values.