logging

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2025 License: Apache-2.0 Imports: 26 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64 added in v0.4.1

func Base64(b []byte) base64Enc

Base64 logs lazily a byte array in base64 format

func Eval added in v0.4.1

func Eval[V any](f func() V) eval[V]

func FilterPrintable added in v0.6.0

func FilterPrintable(s string) (string, bool)

FilterPrintable removes non-printable characters from the passed string. It returns true, if characters have been removed, false otherwise.

func FilterPrintableWithMarker added in v0.6.0

func FilterPrintableWithMarker(s string) string

FilterPrintableWithMarker removes non-printable characters from the passed string. If non-printable characters are found, then a prefix is added to the result.

func GetPackageName added in v0.4.1

func GetPackageName() (string, error)

func Identifier added in v0.4.1

func Identifier(f any) identifier

Identifier logs lazily the identifier of any object

func Init

func Init(c Config)

func Keys added in v0.4.1

func Keys[K comparable, V any](m map[K]V) fmt.Stringer

Keys logs lazily the keys of a map

func NewOtelLogger added in v0.4.1

func NewOtelLogger(zapLogger *zap.Logger) otelLogger

func NewSpecHandler

func NewSpecHandler() http.Handler

func NewTestLogger

func NewTestLogger(tb testing.TB, options ...Option) (Logger, *Recorder)

func OtelSanitize added in v0.6.0

func OtelSanitize() bool

func Prefix added in v0.6.0

func Prefix(id string) fmt.Stringer

func Printable added in v0.6.0

func Printable(id string) fmt.Stringer

func RegisterReplacer added in v0.6.0

func RegisterReplacer(s string, replaceWith string)

RegisterReplacer registers a new replacer for the logger name

func Replacers added in v0.6.0

func Replacers() map[string]string

Replacers returns the current replacers

func Since added in v0.4.1

func Since(t time.Time) since

Types

type Config

type Config struct {
	// Format is the log record format specifier for the Logging instance. If the
	// spec is the string "json", log records will be formatted as JSON. Any
	// other string will be provided to the FormatEncoder. Please see
	// fabenc.ParseFormat for details on the supported verbs.
	//
	// If Format is not provided, a default format that provides basic information will
	// be used.
	Format string
	// LogSpec determines the log levels that are enabled for the logging system. The
	// spec must be in a format that can be processed by ActivateSpec.
	//
	// If LogSpec is not provided, loggers will be enabled at the INFO level.
	LogSpec string
	// Writer is the sink for encoded and formatted log records.
	//
	// If a Writer is not provided, os.Stderr will be used as the log sink.
	Writer io.Writer

	// OtelSanitize when set to true ensures that the strings representing events are first sanitized.
	// Sanitization means that any non-printable character is removed.
	// This protects the traces from undesired behaviours like missing tracing.
	OtelSanitize bool
}

type Logger

type Logger interface {
	With(args ...interface{}) Logger
	Named(name string) Logger
	// contains filtered or unexported methods
}

Logger provides logging API

func GetLogger added in v0.4.1

func GetLogger(params ...string) (Logger, error)

func GetLoggerWithReplacements added in v0.4.1

func GetLoggerWithReplacements(replacements map[string]string, params []string) (Logger, error)

func MustGetLogger

func MustGetLogger(params ...string) Logger

type MockLogger added in v0.4.1

type MockLogger struct{}

func (*MockLogger) Debug added in v0.4.1

func (m *MockLogger) Debug(args ...interface{})

func (*MockLogger) Debugf added in v0.4.1

func (m *MockLogger) Debugf(format string, args ...interface{})

func (*MockLogger) DebugfContext added in v0.4.1

func (m *MockLogger) DebugfContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) DebugwContext added in v0.4.1

func (m *MockLogger) DebugwContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) Error added in v0.4.1

func (m *MockLogger) Error(args ...interface{})

func (*MockLogger) Errorf added in v0.4.1

func (m *MockLogger) Errorf(format string, args ...interface{})

func (*MockLogger) ErrorfContext added in v0.4.1

func (m *MockLogger) ErrorfContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) Errorw added in v0.4.1

func (m *MockLogger) Errorw(format string, args ...interface{})

func (*MockLogger) ErrorwContext added in v0.4.1

func (m *MockLogger) ErrorwContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) Fatal added in v0.4.1

func (m *MockLogger) Fatal(args ...interface{})

func (*MockLogger) Fatalf added in v0.4.1

func (m *MockLogger) Fatalf(format string, args ...interface{})

func (*MockLogger) Info added in v0.4.1

func (m *MockLogger) Info(args ...interface{})

func (*MockLogger) Infof added in v0.4.1

func (m *MockLogger) Infof(format string, args ...interface{})

func (*MockLogger) InfofContext added in v0.4.1

func (m *MockLogger) InfofContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) InfowContext added in v0.4.1

func (m *MockLogger) InfowContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) IsEnabledFor added in v0.4.1

func (m *MockLogger) IsEnabledFor(level zapcore.Level) bool

func (*MockLogger) Named added in v0.4.1

func (m *MockLogger) Named(name string) Logger

func (*MockLogger) Panic added in v0.4.1

func (m *MockLogger) Panic(args ...interface{})

func (*MockLogger) Panicf added in v0.4.1

func (m *MockLogger) Panicf(format string, args ...interface{})

func (*MockLogger) PanicfContext added in v0.4.1

func (m *MockLogger) PanicfContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) PanicwContext added in v0.4.1

func (m *MockLogger) PanicwContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) Warn added in v0.4.1

func (m *MockLogger) Warn(args ...interface{})

func (*MockLogger) Warnf added in v0.4.1

func (m *MockLogger) Warnf(format string, args ...interface{})

func (*MockLogger) WarnfContext added in v0.4.1

func (m *MockLogger) WarnfContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) Warningf added in v0.4.1

func (m *MockLogger) Warningf(format string, args ...interface{})

func (*MockLogger) Warnw added in v0.4.1

func (m *MockLogger) Warnw(format string, args ...interface{})

func (*MockLogger) WarnwContext added in v0.4.1

func (m *MockLogger) WarnwContext(_ context.Context, template string, args ...interface{})

func (*MockLogger) With added in v0.4.1

func (m *MockLogger) With(args ...interface{}) Logger

func (*MockLogger) Zap added in v0.4.1

func (m *MockLogger) Zap() *zap.Logger

type Option

type Option = floggingtest.Option

func Named

func Named(loggerName string) Option

type Recorder

type Recorder = floggingtest.Recorder

Jump to

Keyboard shortcuts

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