log

package
v0.8.0-nightly.20231004 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComponentField        = "component"
	ConnectorIDField      = "connector_id"
	DurationField         = "duration"
	MessageIDField        = "message_id"
	NodeIDField           = "node_id"
	ParallelWorkerIDField = "parallel_worker_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"
	PluginPathField = "plugin_path"

	FilepathField = "filepath"

	InspectorSessionID = "inspector_session_id"
)

Variables

This section is empty.

Functions

func GetWriter added in v0.2.0

func GetWriter(f Format) io.Writer

GetWriter returns a writer according to the log Format

Types

type CtxLogger

type CtxLogger struct {
	zerolog.Logger
	// contains filtered or unexported fields
}

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

func InitLogger(level zerolog.Level, f Format) CtxLogger

InitLogger returns a logger initialized with the wanted level and format

func New

func New(logger zerolog.Logger) CtxLogger

New creates a new CtxLogger with the supplied zerolog.Logger.

func Nop

func Nop() CtxLogger

Nop returns a disabled logger for which all operation are no-op.

func (CtxLogger) Component

func (l CtxLogger) Component() string

func (CtxLogger) Debug

func (l CtxLogger) Debug(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Err(ctx context.Context, err error) *zerolog.Event

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

func (l CtxLogger) Error(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Fatal(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Info(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Log(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Panic(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Trace(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) Warn(ctx context.Context) *zerolog.Event

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

func (l CtxLogger) WithComponent(component string) CtxLogger

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

func (l CtxLogger) WithLevel(ctx context.Context, level zerolog.Level) *zerolog.Event

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

func (l CtxLogger) ZerologWithComponent() zerolog.Logger

ZerologWithComponent returns a zerolog.Logger that adds the component field to all log entries.

type Format added in v0.2.0

type Format int
const (
	FormatCLI Format = iota
	FormatJSON
)

func ParseFormat added in v0.2.0

func ParseFormat(format string) (Format, error)

ParseFormat converts a format string into a log Format value. returns an error if the input string does not match known values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL