Documentation
¶
Overview ¶
Package log provides a simplified and opinionated interface for structured logging, built on top of the high-performance zap logger. It offers a global logger instance that can be configured once and used throughout the application.
Package log provides a simplified and opinionated interface for structured logging, built on top of the high-performance zap logger.
Package log provides a simplified and opinionated interface for structured logging, built on top of the high-performance zap logger.
Package log provides a simplified and opinionated interface for structured logging, built on top of the high-performance zap logger.
Index ¶
- func Debug(msg string, fields ...Field)
- func Debugf(format string, a ...any)
- func Error(msg string, fields ...Field)
- func Errorf(format string, a ...any)
- func Fatal(msg string, fields ...Field)
- func Fatalf(format string, a ...any)
- func Info(msg string, fields ...Field)
- func Infof(format string, a ...any)
- func Panic(msg string, fields ...Field)
- func SetConfig(opts ...Option)
- func Warn(msg string, fields ...Field)
- func Warnf(format string, a ...any)
- type Config
- type Field
- func Any(key string, val any) Field
- func Bool(key string, val bool) Field
- func ByteString(key string, val []byte) Field
- func Duration(key string, val time.Duration) Field
- func Err(err error) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int32(key string, val int32) Field
- func Int64(key string, val int64) Field
- func String(key string, val string) Field
- func Stringer(key string, val fmt.Stringer) Field
- func Time(key string, val time.Time) Field
- func Uint(key string, val uint) Field
- func Uint32(key string, val uint32) Field
- func Uint64(key string, val uint64) Field
- func Uintptr(key string, val uintptr) Field
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetConfig ¶
func SetConfig(opts ...Option)
SetConfig applies user-defined options to the default logger configuration. This should be called before the first log message is written to have an effect.
Types ¶
type Field ¶
Field is a type alias for zapcore.Field, representing a single key-value pair in a structured log. Using a type alias provides a convenient, shorter way to reference this type.
func Any ¶
Any creates a Field with a value of any type, using reflection for serialization. It is useful for logging complex types like structs, slices, and maps.
func ByteString ¶
ByteString creates a Field with a byte slice value.
type Option ¶
type Option func(*Config)
Option defines a function that configures the logger. This follows the functional options pattern for clean and extensible configuration.
func WithCallerSkip ¶
WithCallerSkip sets the number of stack frames to skip when logging caller info.
func WithDev ¶
WithDev configures the logger to run in development mode. In development mode, logs are more human-readable, with colored levels and custom time formatting.
func WithLevel ¶
WithLevel sets the minimum logging level. Only logs at or above this level will be written. Valid levels are "debug", "info", "warn", "error".
func WithServiceName ¶
WithServiceName sets the name of the service that is logging.