Documentation
¶
Overview ¶
Package sflog package defines the logging interface for Snowflake's Go driver. If you want to implement a custom logger, you should implement the SFLogger interface defined in this package.
Index ¶
Constants ¶
const ( LevelTrace = Level(-8) LevelDebug = Level(-4) LevelInfo = Level(0) LevelWarn = Level(4) LevelError = Level(8) LevelFatal = Level(12) LevelOff = Level(math.MaxInt) )
Custom level constants that extend slog's standard levels
Variables ¶
This section is empty.
Functions ¶
func LevelToString ¶
LevelToString converts Level to string
Types ¶
type ClientLogContextHook ¶
ClientLogContextHook is a client-defined hook that can be used to insert log fields based on the Context.
type Level ¶
type Level int
Level represents the log level for a log message. It extends slog's standard levels with custom levels.
func ParseLevel ¶
ParseLevel converts a string level to Level
type LogEntry ¶
type LogEntry interface {
Tracef(format string, args ...interface{})
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Warnf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Trace(msg string)
Debug(msg string)
Info(msg string)
Warn(msg string)
Error(msg string)
Fatal(msg string)
}
LogEntry allows for logging using a snapshot of field values. No implementation-specific logging details should be placed into this interface.
type SFLogger ¶
type SFLogger interface {
LogEntry
WithField(key string, value interface{}) LogEntry
WithFields(fields map[string]any) LogEntry
SetLogLevel(level string) error
SetLogLevelInt(level Level) error
GetLogLevel() string
GetLogLevelInt() Level
WithContext(ctx context.Context) LogEntry
SetOutput(output io.Writer)
}
SFLogger Snowflake logger interface which abstracts away the underlying logging mechanism. No implementation-specific logging details should be placed into this interface.
type SFSlogLogger ¶
SFSlogLogger is an optional interface for advanced slog handler configuration. This interface is separate from SFLogger to maintain framework-agnostic design. Users can type-assert the logger to check if slog handler configuration is supported.
Example usage:
logger := gosnowflake.GetLogger()
if slogLogger, ok := logger.(gosnowflake.SFSlogLogger); ok {
customHandler := slog.NewJSONHandler(os.Stdout, nil)
slogLogger.SetHandler(customHandler)
}