Documentation
¶
Overview ¶
Package log provides a shared zap logger for all components.
Index ¶
- Variables
- func Any(key string, val any) zap.Field
- func Bool(key string, val bool) zap.Field
- func Debug(msg string, fields ...zap.Field)
- func Err(err error) zap.Field
- func Error(msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func Info(msg string, fields ...zap.Field)
- func Init(cfg Config) error
- func InitFromEnv() error
- func Int(key string, val int) zap.Field
- func Int64(key string, val int64) zap.Field
- func String(key, val string) zap.Field
- func Sync()
- func Warn(msg string, fields ...zap.Field)
- func With(fields ...zap.Field) *zap.Logger
- func WithComponent(component string) *zap.Logger
- type Config
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // L is the global logger instance. L *zap.Logger // S is the global sugared logger for convenience (printf-style logging). S *zap.SugaredLogger )
Functions ¶
func InitFromEnv ¶
func InitFromEnv() error
InitFromEnv initializes the logger from environment variables LOG_LEVEL: debug, info, warn, error (default: info) LOG_FORMAT: json, console (default: json) LOG_DEV: true/false - enables development mode (default: false).
func Sync ¶
func Sync()
Sync flushes any buffered log entries. Should be called before program exit.
func WithComponent ¶
WithComponent creates a child logger with a component field.
Types ¶
type Config ¶
type Config struct {
// Level is the minimum log level (debug, info, warn, error)
Level string
// Format is the output format (json, console)
Format string
// Development enables development mode (more verbose, stack traces)
Development bool
}
Config holds logger configuration.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for production.
Click to show internal directories.
Click to hide internal directories.