Documentation
¶
Index ¶
- func CloseFileOnLoggerReplace(sflog interface{}, file *os.File) error
- func CreateDefaultLogger() sflog.SFLogger
- func GetClientLogContextHooks() map[string]ClientLogContextHook
- func GetLogKeys() []interface{}
- func GetLogger() sflog.SFLogger
- func IsEasyLoggingLogger(sflog interface{}) bool
- func MaskSecrets(text string) (masked string)
- func NewLoggerProxy() sflog.SFLogger
- func RegisterLogContextHook(key string, hook ClientLogContextHook)
- func SetLogKeys(keys []interface{})
- func SetLogger(providedLogger SFLogger) error
- type ClientLogContextHook
- type EasyLoggingSupport
- type LogEntry
- type Proxy
- func (p *Proxy) Debug(msg string)
- func (p *Proxy) Debugf(format string, args ...interface{})
- func (p *Proxy) Error(msg string)
- func (p *Proxy) Errorf(format string, args ...interface{})
- func (p *Proxy) Fatal(msg string)
- func (p *Proxy) Fatalf(format string, args ...interface{})
- func (p *Proxy) GetLogLevel() string
- func (p *Proxy) GetLogLevelInt() sflog.Level
- func (p *Proxy) Info(msg string)
- func (p *Proxy) Infof(format string, args ...interface{})
- func (p *Proxy) SetHandler(handler slog.Handler) error
- func (p *Proxy) SetLogLevel(level string) error
- func (p *Proxy) SetLogLevelInt(level sflog.Level) error
- func (p *Proxy) SetOutput(output io.Writer)
- func (p *Proxy) Trace(msg string)
- func (p *Proxy) Tracef(format string, args ...interface{})
- func (p *Proxy) Warn(msg string)
- func (p *Proxy) Warnf(format string, args ...interface{})
- func (p *Proxy) WithContext(ctx context.Context) sflog.LogEntry
- func (p *Proxy) WithField(key string, value interface{}) sflog.LogEntry
- func (p *Proxy) WithFields(fields map[string]any) sflog.LogEntry
- type SFLogger
- type Unwrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseFileOnLoggerReplace ¶
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 ¶
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 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 ¶
MaskSecrets masks secrets in text (exported for use by main package and secret masking logger)
func NewLoggerProxy ¶
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 ¶
SetLogger sets the raw (base) logger implementation and wraps it with the standard protection layers. This function ALWAYS wraps the provided logger with:
- Secret masking (to protect sensitive data)
- 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 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 ¶
Debug implements the Debug method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Debugf ¶
Debugf implements the Debugf method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Error ¶
Error implements the Error method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Errorf ¶
Errorf implements the Errorf method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Fatal ¶
Fatal implements the Fatal method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Fatalf ¶
Fatalf implements the Fatalf method of the SFLogger interface by delegating to the global logger.
func (*Proxy) GetLogLevel ¶
GetLogLevel implements the GetLogLevel method of the SFLogger interface by delegating to the global logger.
func (*Proxy) GetLogLevelInt ¶
GetLogLevelInt implements the GetLogLevelInt method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Info ¶
Info implements the Info method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Infof ¶
Infof implements the Infof method of the SFLogger interface by delegating to the global logger.
func (*Proxy) SetHandler ¶
SetHandler implements SFSlogLogger interface for advanced slog handler configuration. This delegates to the underlying logger if it supports SetHandler.
func (*Proxy) SetLogLevel ¶
SetLogLevel implements the SetLogLevel method of the SFLogger interface by delegating to the global logger.
func (*Proxy) SetLogLevelInt ¶
SetLogLevelInt implements the SetLogLevelInt method of the SFLogger interface by delegating to the global logger.
func (*Proxy) SetOutput ¶
SetOutput implements the SetOutput method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Trace ¶
Trace implements the Trace method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Tracef ¶
Tracef implements the Tracef method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Warn ¶
Warn implements the Warn method of the SFLogger interface by delegating to the global logger.
func (*Proxy) Warnf ¶
Warnf implements the Warnf method of the SFLogger interface by delegating to the global logger.
func (*Proxy) WithContext ¶
WithContext implements the WithContext method of the SFLogger interface by delegating to the global logger.