Documentation
¶
Index ¶
- Constants
- Variables
- func DebugCf(ctx context.Context, format string, args ...any)
- func DebugCw(ctx context.Context, msg string, keysAndValues ...any)
- func Debugf(format string, args ...any)
- func Debugw(msg string, keysAndValues ...any)
- func ErrorCf(ctx context.Context, format string, args ...any)
- func ErrorCw(ctx context.Context, msg string, keysAndValues ...any)
- func Errorf(format string, args ...any)
- func Errorw(msg string, keysAndValues ...any)
- func FatalCf(ctx context.Context, format string, args ...any)
- func FatalCw(ctx context.Context, msg string, keysAndValues ...any)
- func Fatalf(format string, args ...any)
- func Fatalw(msg string, keysAndValues ...any)
- func FromContext(ctx context.Context) logr.Logger
- func FromRequest(r *http.Request) logr.Logger
- func InfoCf(ctx context.Context, format string, args ...any)
- func InfoCw(ctx context.Context, msg string, keysAndValues ...any)
- func Infof(format string, args ...any)
- func Infow(msg string, keysAndValues ...any)
- func LogSinkFromContext(ctx context.Context) *zap.Logger
- func NewLoggerFromEnv() (*zap.Logger, error)
- func NewZapLog(cfg *LogConfig) (*zap.Logger, error)
- func PanicCf(ctx context.Context, format string, args ...any)
- func PanicCw(ctx context.Context, msg string, keysAndValues ...any)
- func Panicf(format string, args ...any)
- func Panicw(msg string, keysAndValues ...any)
- func PrintCf(ctx context.Context, format string, args ...any)
- func PrintCw(ctx context.Context, msg string, keysAndValues ...any)
- func Printf(format string, args ...any)
- func Printw(msg string, keysAndValues ...any)
- func VCf(ctx context.Context, level int, format string, args ...any)
- func Vf(level int, format string, args ...any)
- func WarnCf(ctx context.Context, format string, args ...any)
- func WarnCw(ctx context.Context, msg string, keysAndValues ...any)
- func Warnf(format string, args ...any)
- func Warnw(msg string, keysAndValues ...any)
- func WithContext(ctx context.Context, logger logr.Logger) context.Context
- type LogConfig
Constants ¶
View Source
const ( LogLevelDebug = "debug" LogLevelInfo = "info" LogLevelWarn = "warn" LogLevelError = "error" LogLevelFatal = "fatal" )
View Source
const ( LogFormatJson = "json" LogFormatText = "text" )
Variables ¶
View Source
var LogSink *zap.Logger
View Source
var Logger logr.Logger
Functions ¶
func NewLoggerFromEnv ¶
Types ¶
type LogConfig ¶
type LogConfig struct {
Level string `env:"LOG_LEVEL" envDefault:"info"`
Format string `env:"LOG_FORMAT"`
// TimeFormat controls how timestamps are encoded in logs.
// Supported values:
// - "epoch" → seconds since Unix epoch (default Zap behavior)
// - "epoch_ms"→ milliseconds since epoch
// - "iso8601" → "2025-10-31T17:49:44.023Z"
// - "rfc3339" → "2025-10-31T17:49:44Z"
// Default is "epoch".
TimeFormat string `env:"LOG_TIME_FORMAT" envDefault:"epoch"`
}
func ConfigFromEnv ¶
Click to show internal directories.
Click to hide internal directories.