logger

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFileOnLoggerReplace

func CloseFileOnLoggerReplace(sflog interface{}, file *os.File) error

CloseFileOnLoggerReplace closes a log file when the logger is replaced. This is used by the easy logging feature to manage log file handles.

func CreateDefaultLogger

func CreateDefaultLogger() sflog.SFLogger

CreateDefaultLogger function creates a new instance of the default logger with the standard protection layers.

func GetClientLogContextHooks

func GetClientLogContextHooks() map[string]ClientLogContextHook

GetClientLogContextHooks returns a copy of registered hooks

func GetLogKeys

func GetLogKeys() []interface{}

GetLogKeys returns a copy of the current log keys

func GetLogger

func GetLogger() sflog.SFLogger

GetLogger returns the global logger for use by internal packages

func IsEasyLoggingLogger

func IsEasyLoggingLogger(sflog interface{}) bool

IsEasyLoggingLogger checks if the given logger is based on the default logger implementation. This is used by easy logging to determine if reconfiguration is allowed.

func MaskSecrets

func MaskSecrets(text string) (masked string)

MaskSecrets masks secrets in text (exported for use by main package and secret masking logger)

func NewLoggerProxy

func NewLoggerProxy() sflog.SFLogger

NewLoggerProxy creates a new logger proxy that delegates all calls to the global logger managed by the internal package.

func RegisterLogContextHook

func RegisterLogContextHook(key string, hook ClientLogContextHook)

RegisterLogContextHook registers a hook for extracting context fields This function is thread-safe and can be called at runtime.

func SetLogKeys

func SetLogKeys(keys []interface{})

SetLogKeys sets the context keys to be extracted from context This function is thread-safe and can be called at runtime.

func SetLogger

func SetLogger(providedLogger SFLogger) error

SetLogger sets the raw (base) logger implementation and wraps it with the standard protection layers. This function ALWAYS wraps the provided logger with:

  1. Secret masking (to protect sensitive data)
  2. Level filtering (for performance optimization)

There is no way to bypass these protective layers. The globalLogger structure is:

globalLogger = levelFilteringLogger → secretMaskingLogger → rawLogger

If the provided logger is already wrapped (e.g., from CreateDefaultLogger), this function automatically extracts the raw logger to prevent double-wrapping.

Internal wrapper types that would cause issues are rejected:

  • Proxy (would cause infinite recursion)

Types

type ClientLogContextHook

type ClientLogContextHook = sflog.ClientLogContextHook

ClientLogContextHook reexports the ClientLogContextHook type from sflog package.

type EasyLoggingSupport

type EasyLoggingSupport interface {
	// CloseFileOnLoggerReplace closes the logger's file handle when logger is replaced
	CloseFileOnLoggerReplace(file *os.File) error
}

EasyLoggingSupport is an optional interface for loggers that support easy_logging.go functionality. This is used for file-based logging configuration.

type LogEntry

type LogEntry = sflog.LogEntry

LogEntry reexports the LogEntry interface from sflog package.

type Proxy

type Proxy struct{}

Proxy is a proxy that delegates all calls to the global logger. This ensures a single source of truth for the current logger.

func (*Proxy) Debug

func (p *Proxy) Debug(msg string)

Debug implements the Debug method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Debugf

func (p *Proxy) Debugf(format string, args ...interface{})

Debugf implements the Debugf method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Error

func (p *Proxy) Error(msg string)

Error implements the Error method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Errorf

func (p *Proxy) Errorf(format string, args ...interface{})

Errorf implements the Errorf method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Fatal

func (p *Proxy) Fatal(msg string)

Fatal implements the Fatal method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Fatalf

func (p *Proxy) Fatalf(format string, args ...interface{})

Fatalf implements the Fatalf method of the SFLogger interface by delegating to the global logger.

func (*Proxy) GetLogLevel

func (p *Proxy) GetLogLevel() string

GetLogLevel implements the GetLogLevel method of the SFLogger interface by delegating to the global logger.

func (*Proxy) GetLogLevelInt

func (p *Proxy) GetLogLevelInt() sflog.Level

GetLogLevelInt implements the GetLogLevelInt method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Info

func (p *Proxy) Info(msg string)

Info implements the Info method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Infof

func (p *Proxy) Infof(format string, args ...interface{})

Infof implements the Infof method of the SFLogger interface by delegating to the global logger.

func (*Proxy) SetHandler

func (p *Proxy) SetHandler(handler slog.Handler) error

SetHandler implements SFSlogLogger interface for advanced slog handler configuration. This delegates to the underlying logger if it supports SetHandler.

func (*Proxy) SetLogLevel

func (p *Proxy) SetLogLevel(level string) error

SetLogLevel implements the SetLogLevel method of the SFLogger interface by delegating to the global logger.

func (*Proxy) SetLogLevelInt

func (p *Proxy) SetLogLevelInt(level sflog.Level) error

SetLogLevelInt implements the SetLogLevelInt method of the SFLogger interface by delegating to the global logger.

func (*Proxy) SetOutput

func (p *Proxy) SetOutput(output io.Writer)

SetOutput implements the SetOutput method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Trace

func (p *Proxy) Trace(msg string)

Trace implements the Trace method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Tracef

func (p *Proxy) Tracef(format string, args ...interface{})

Tracef implements the Tracef method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Warn

func (p *Proxy) Warn(msg string)

Warn implements the Warn method of the SFLogger interface by delegating to the global logger.

func (*Proxy) Warnf

func (p *Proxy) Warnf(format string, args ...interface{})

Warnf implements the Warnf method of the SFLogger interface by delegating to the global logger.

func (*Proxy) WithContext

func (p *Proxy) WithContext(ctx context.Context) sflog.LogEntry

WithContext implements the WithContext method of the SFLogger interface by delegating to the global logger.

func (*Proxy) WithField

func (p *Proxy) WithField(key string, value interface{}) sflog.LogEntry

WithField implements the WithField method of the SFLogger interface by delegating to the global logger.

func (*Proxy) WithFields

func (p *Proxy) WithFields(fields map[string]any) sflog.LogEntry

WithFields implements the WithFields method of the SFLogger interface by delegating to the global logger.

type SFLogger

type SFLogger = sflog.SFLogger

SFLogger reexports the SFLogger interface from sflog package.

type Unwrapper

type Unwrapper interface {
	Unwrap() interface{}
}

Unwrapper is a common interface for unwrapping wrapped loggers

Jump to

Keyboard shortcuts

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