log

package
v0.0.0-...-4fbbd1a Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// CloneWithUpdates - returns a new client with the given attributes in each output
	CloneWithUpdates(
		debugFunc DebugFunc,
		debugContextFunc DebugContextFunc,
		enabledFunc EnabledFunc,
		errorFunc ErrorFunc,
		errorContextFunc ErrorContextFunc,
		handlerFunc HandlerFunc,
		infoFunc InfoFunc,
		infoContextFunc InfoContextFunc,
		logFunc LogFunc,
		logAttrsFunc LogAttrsFunc,
		logger *slog.Logger,
		warnFunc WarnFunc,
		warnContextFunc WarnContextFunc,
		withFunc WithFunc,
		withGroupFunc WithGroupFunc,
	) Client
	// Debug - log a debug message
	Debug(format string, args ...interface{})
	// DebugContext - log a debug message with context
	DebugContext(context context.Context, format string, args ...interface{})
	// Enabled - check if logs will emit with given context and level
	Enabled(context context.Context, level slog.Level) bool
	// Error - log an error
	Error(format string, args ...interface{})
	// ErrorContext - log an error
	ErrorContext(context context.Context, format string, args ...interface{})
	// Handler - return a slog.Handler in use by the client
	Handler() slog.Handler
	// Info - log an info message
	Info(format string, args ...interface{})
	// InfoContext - log an info message with context
	InfoContext(context context.Context, format string, args ...interface{})
	// Log - log a message
	Log(context context.Context, level slog.Level, format string, args ...interface{})
	// LogAttrs - log a message with attributes
	LogAttrs(context context.Context, level slog.Level, msg string, attrs ...slog.Attr)
	// Logger - return the logger in use by the client
	Logger() *slog.Logger
	// Warn - log a warning message
	Warn(format string, args ...interface{})
	// WarnContext - log a warning message with context
	WarnContext(context context.Context, format string, args ...interface{})
	// With - returns a new client with the given attributes in each output
	With(args ...interface{}) *Client
	// WithGroup - returns a new client with the group for each output (affects all other attrs given the handler's processing)
	WithGroup(group string) *Client
}

Client holds the functions to handle logging

func NewClient

func NewClient(
	debugFunc DebugFunc,
	debugContextFunc DebugContextFunc,
	enabledFunc EnabledFunc,
	errorFunc ErrorFunc,
	errorContextFunc ErrorContextFunc,
	handlerFunc HandlerFunc,
	infoFunc InfoFunc,
	infoContextFunc InfoContextFunc,
	logFunc LogFunc,
	logAttrsFunc LogAttrsFunc,
	logger *slog.Logger,
	warnFunc WarnFunc,
	warnContextFunc WarnContextFunc,
	withFunc WithFunc,
	withGroupFunc WithGroupFunc,
) Client

NewClient returns a new Logging client with the provided configuration

type ClientGetter

type ClientGetter struct{}

ClientGetter is an interface for getting an BB log client.

func (*ClientGetter) GetClient

func (clientGetter *ClientGetter) GetClient(logger *slog.Logger) Client

GetClient returns a new log client.

type DebugContextFunc

type DebugContextFunc func(context.Context, Client, string, ...interface{})

DebugContextFunc type

type DebugFunc

type DebugFunc func(Client, string, ...interface{})

DebugFunc type

type EnabledFunc

type EnabledFunc func(context.Context, Client, slog.Level) bool

EnabledFunc type

type ErrorContextFunc

type ErrorContextFunc func(context.Context, Client, string, ...interface{})

ErrorContextFunc type

type ErrorFunc

type ErrorFunc func(Client, string, ...interface{})

ErrorFunc type

type HandlerFunc

type HandlerFunc func(Client) slog.Handler

HandlerFunc type

type InfoContextFunc

type InfoContextFunc func(context.Context, Client, string, ...interface{})

InfoContextFunc type

type InfoFunc

type InfoFunc func(Client, string, ...interface{})

InfoFunc type

type LogAttrsFunc

type LogAttrsFunc func(context.Context, Client, slog.Level, string, ...slog.Attr) //nolint:revive

LogAttrsFunc type // golangci-lint complains about stuttering, but this is the best name for this type

type LogFunc

type LogFunc func(context.Context, Client, slog.Level, string, ...interface{}) //nolint:revive

LogFunc type // golangci-lint complains about stuttering, but this is the best name for this type

type TestLog

type TestLog struct {
	Time    string        `json:"time"`
	Level   string        `json:"level"`
	Source  TestLogSource `json:"source"`
	Message string        `json:"msg"`
}

TestLog type

type TestLogSource

type TestLogSource struct {
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
}

TestLogSource type

type WarnContextFunc

type WarnContextFunc func(context.Context, Client, string, ...interface{})

WarnContextFunc type

type WarnFunc

type WarnFunc func(Client, string, ...interface{})

WarnFunc type

type WithFunc

type WithFunc func(Client, ...interface{}) *Client

WithFunc type

type WithGroupFunc

type WithGroupFunc func(Client, string) *Client

WithGroupFunc type

Jump to

Keyboard shortcuts

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