Documentation
¶
Overview ¶
Package loggergo provides functionality for configuring and setting up different logging modes in Go applications. It includes support for OpenTelemetry format, JSON format, and plain format with different flavors. The package also supports enabling OpenTelemetry tracing for the logs.
Index ¶
- Variables
- func GetLogLevelAccessor() *slog.LevelVar
- func Init(ctx context.Context, config types.Config, additionalAttrs ...any) (context.Context, *slog.Logger, error)
- type Config
- type CustomContextAttributeHandler
- func (h *CustomContextAttributeHandler) Enabled(ctx context.Context, level slog.Level) bool
- func (h *CustomContextAttributeHandler) Handle(ctx context.Context, record slog.Record) error
- func (h *CustomContextAttributeHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *CustomContextAttributeHandler) WithGroup(name string) slog.Handler
Constants ¶
This section is empty.
Variables ¶
View Source
var Types = struct { AllDevFlavors func() []types.DevFlavor DevFlavorFromString func(string) types.DevFlavor DevFlavorTint types.DevFlavor DevFlavorSlogor types.DevFlavor DevFlavorDevslog types.DevFlavor AllLogFormats func() []types.LogFormat LogFormatFromString func(string) types.LogFormat LogFormatText types.LogFormat LogFormatJSON types.LogFormat LogFormatOtel types.LogFormat AllLogLevels func() []slog.Level LogLevelFromString func(string) slog.Level AllOutputTypes func() []types.OutputType OutputTypeFromString func(string) types.OutputType OutputConsole types.OutputType OutputOtel types.OutputType OutputFanout types.OutputType }{ AllDevFlavors: types.AllDevFlavors, DevFlavorFromString: types.DevFlavorFromString, DevFlavorTint: types.DevFlavorTint, DevFlavorSlogor: types.DevFlavorSlogor, DevFlavorDevslog: types.DevFlavorDevslog, AllLogFormats: types.AllLogFormats, LogFormatFromString: types.LogFormatFromString, LogFormatText: types.LogFormatText, LogFormatJSON: types.LogFormatJSON, LogFormatOtel: types.LogFormatOtel, AllLogLevels: types.AllLogLevels, LogLevelFromString: types.LogLevelFromString, AllOutputTypes: types.AllOutputTypes, OutputTypeFromString: types.OutputTypeFromString, OutputConsole: types.OutputConsole, OutputOtel: types.OutputOtel, OutputFanout: types.OutputFanout, }
Functions ¶
func GetLogLevelAccessor ¶ added in v1.5.5
Types ¶
type CustomContextAttributeHandler ¶ added in v1.6.0
type CustomContextAttributeHandler struct { ContextKeysDefault interface{} // contains filtered or unexported fields }
CustomContextAttributeHandler wraps an existing handler and adds a custom attribute to all logs.
func NewCustomContextAttributeHandler ¶ added in v1.6.0
func NewCustomContextAttributeHandler(handler slog.Handler, keys []interface{}, contextKeysDefault interface{}) *CustomContextAttributeHandler
NewCustomContextAttributeHandler creates a new handler that wraps the given handler and adds a custom attribute.
func (*CustomContextAttributeHandler) Enabled ¶ added in v1.6.0
Enabled delegates the Enabled check to the inner handler.
func (*CustomContextAttributeHandler) Handle ¶ added in v1.6.0
Handle adds the custom attribute and delegates the log processing to the inner handler.
Click to show internal directories.
Click to hide internal directories.