Documentation
¶
Index ¶
- Variables
- func Debug(msg string, keysAndValues ...interface{})
- func Error(msg string, keysAndValues ...interface{})
- func Fatal(msg string, keysAndValues ...interface{})
- func Info(msg string, keysAndValues ...interface{})
- func SetGlobalLogger(logger *Logger)
- func SetLevel(level string)
- func Sync()
- func Warn(msg string, keysAndValues ...interface{})
- type Config
- type Entry
- type Level
- type Logger
- func (l *Logger) Debug(msg string, keysAndValues ...interface{})
- func (l *Logger) Error(msg string, keysAndValues ...interface{})
- func (l *Logger) Fatal(msg string, keysAndValues ...interface{})
- func (l *Logger) Info(msg string, keysAndValues ...interface{})
- func (l *Logger) Warn(msg string, keysAndValues ...interface{})
- func (l *Logger) WithContext(ctx context.Context) *Logger
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalLogger = Default()
GlobalLogger is the default logger instance
Functions ¶
func Fatal ¶
func Fatal(msg string, keysAndValues ...interface{})
Fatal logs to the global logger and exits
func SetGlobalLogger ¶
func SetGlobalLogger(logger *Logger)
SetGlobalLogger sets the global logger instance
Types ¶
type Config ¶
type Config struct {
Level string `json:"level"`
Format string `json:"format"`
Output string `json:"output"`
Structured bool `json:"structured"`
Service string `json:"service"`
Version string `json:"version"`
}
Config holds logger configuration
type Entry ¶
type Entry struct {
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"`
Message string `json:"message"`
Service string `json:"service,omitempty"`
Version string `json:"version,omitempty"`
RequestID string `json:"request_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
UserID string `json:"user_id,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
File string `json:"file,omitempty"`
Function string `json:"function,omitempty"`
Line int `json:"line,omitempty"`
Fields map[string]interface{} `json:"fields,omitempty"`
Error string `json:"error,omitempty"`
StackTrace []string `json:"stack_trace,omitempty"`
}
Entry represents a log entry
type Level ¶
type Level int
Level represents a logging level
func LevelFromString ¶
LevelFromString converts a string to a Level
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a structured logger
func ContextLogger ¶
ContextLogger extracts logger with context information
func NewFromConfig ¶
NewFromConfig creates a logger from a configuration struct
Click to show internal directories.
Click to hide internal directories.