Documentation ¶
Index ¶
- func Debug(msg string, args ...any)
- func Error(msg string, args ...any)
- func GetLevel() slog.Level
- func Info(msg string, args ...any)
- func OnDebug(cb LogCallback)
- func OnError(cb LogCallback)
- func OnInfo(cb LogCallback)
- func OnWarn(cb LogCallback)
- func ParseLevel(levelStr string) (slog.Level, error)
- func RegisterCallback(level slog.Level, cb LogCallback)
- func RegisterStringer[T any](converter func(T) string)
- func SetLevel(level slog.Level)
- func Setup(levelStr string) error
- func StopFile() error
- func StopLoki()
- func UseFile(cfg FileConfig) error
- func UseLoki(cfg LokiConfig) error
- func UseMssqlDb(cfg DbConfig) error
- func UseMysqlDb(cfg DbConfig) error
- func UsePostgresDb(cfg DbConfig) error
- func UseSqlite(cfg DbConfig) error
- func Warn(msg string, args ...any)
- type DbConfig
- type FileConfig
- type LogCallback
- type Logger
- type LokiConfig
- type StringConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnError ¶
func OnError(cb LogCallback)
func OnInfo ¶
func OnInfo(cb LogCallback)
func OnWarn ¶
func OnWarn(cb LogCallback)
func ParseLevel ¶ added in v2.0.4
ParseLevel converts a string to a slog.Level
func RegisterCallback ¶
func RegisterCallback(level slog.Level, cb LogCallback)
RegisterCallback registers a callback function for the specified level
func RegisterStringer ¶ added in v2.0.4
RegisterStringer registers a custom string conversion function for a specific type
func UseFile ¶
func UseFile(cfg FileConfig) error
UseFile sets up logging callbacks that write logs to the specified file
func UseLoki ¶
func UseLoki(cfg LokiConfig) error
UseLoki sets up logging callbacks that send logs to a Loki instance
func UseMssqlDb ¶ added in v2.0.4
UseMssqlDb sets up logging to a Microsoft SQL Server database
func UseMysqlDb ¶ added in v2.0.4
UseMysqlDb sets up logging to a MySQL database
func UsePostgresDb ¶ added in v2.0.4
UsePostgresDb sets up logging to a PostgreSQL database
Types ¶
type FileConfig ¶
type FileConfig struct { Path string // Path to the log file TimeFormat string // Format for timestamps, defaults to time.RFC3339 FormatJson bool // Whether to format logs as JSON LabelsMap map[string]string // Labels to be included with every log entry MinLevel *slog.Level // Minimum log level to write to file }
type LogCallback ¶
LogCallback is the function signature for log event subscribers
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents the global logger instance
type LokiConfig ¶
type LokiConfig struct { URL string // Loki server URL BatchWait time.Duration // Maximum amount of time to wait before sending a batch Labels map[string]string // Default labels to add to all logs Tenant string // Optional tenant ID for multi-tenancy MinLevel *slog.Level // Minimum log level to send to Loki }
type StringConverter ¶ added in v2.0.4
StringConverter is a function that converts a value to its string representation