zlog

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

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 DebugCf

func DebugCf(ctx context.Context, format string, args ...any)

func DebugCw

func DebugCw(ctx context.Context, msg string, keysAndValues ...any)

func Debugf

func Debugf(format string, args ...any)

func Debugw

func Debugw(msg string, keysAndValues ...any)

func ErrorCf

func ErrorCf(ctx context.Context, format string, args ...any)

func ErrorCw

func ErrorCw(ctx context.Context, msg string, keysAndValues ...any)

func Errorf

func Errorf(format string, args ...any)

func Errorw

func Errorw(msg string, keysAndValues ...any)

func FatalCf

func FatalCf(ctx context.Context, format string, args ...any)

func FatalCw

func FatalCw(ctx context.Context, msg string, keysAndValues ...any)

func Fatalf

func Fatalf(format string, args ...any)

func Fatalw

func Fatalw(msg string, keysAndValues ...any)

func FromContext

func FromContext(ctx context.Context) logr.Logger

func FromRequest

func FromRequest(r *http.Request) logr.Logger

func InfoCf

func InfoCf(ctx context.Context, format string, args ...any)

func InfoCw

func InfoCw(ctx context.Context, msg string, keysAndValues ...any)

func Infof

func Infof(format string, args ...any)

func Infow

func Infow(msg string, keysAndValues ...any)

func LogSinkFromContext

func LogSinkFromContext(ctx context.Context) *zap.Logger

func NewLoggerFromEnv

func NewLoggerFromEnv() (*zap.Logger, error)

func NewZapLog

func NewZapLog(cfg *LogConfig) (*zap.Logger, error)

func PanicCf

func PanicCf(ctx context.Context, format string, args ...any)

func PanicCw

func PanicCw(ctx context.Context, msg string, keysAndValues ...any)

func Panicf

func Panicf(format string, args ...any)

func Panicw

func Panicw(msg string, keysAndValues ...any)

func PrintCf

func PrintCf(ctx context.Context, format string, args ...any)

func PrintCw

func PrintCw(ctx context.Context, msg string, keysAndValues ...any)

func Printf

func Printf(format string, args ...any)

func Printw

func Printw(msg string, keysAndValues ...any)

func VCf

func VCf(ctx context.Context, level int, format string, args ...any)

func Vf

func Vf(level int, format string, args ...any)

func WarnCf

func WarnCf(ctx context.Context, format string, args ...any)

func WarnCw

func WarnCw(ctx context.Context, msg string, keysAndValues ...any)

func Warnf

func Warnf(format string, args ...any)

func Warnw

func Warnw(msg string, keysAndValues ...any)

func WithContext

func WithContext(ctx context.Context, logger logr.Logger) context.Context

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

func ConfigFromEnv() (*LogConfig, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL