log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package log provides a shared zap logger for all components.

Index

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 Any

func Any(key string, val any) zap.Field

Any is a shortcut for zap.Any.

func Bool

func Bool(key string, val bool) zap.Field

Bool is a shortcut for zap.Bool.

func Debug

func Debug(msg string, fields ...zap.Field)

Debug logs a debug message.

func Err

func Err(err error) zap.Field

Err is a shortcut for zap.Error.

func Error

func Error(msg string, fields ...zap.Field)

Error logs an error message.

func Fatal

func Fatal(msg string, fields ...zap.Field)

Fatal logs a fatal message and exits.

func Info

func Info(msg string, fields ...zap.Field)

Info logs an info message.

func Init

func Init(cfg Config) error

Init initializes the global logger with the given configuration.

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 Int

func Int(key string, val int) zap.Field

Int is a shortcut for zap.Int.

func Int64

func Int64(key string, val int64) zap.Field

Int64 is a shortcut for zap.Int64.

func String

func String(key, val string) zap.Field

String is a shortcut for zap.String.

func Sync

func Sync()

Sync flushes any buffered log entries. Should be called before program exit.

func Warn

func Warn(msg string, fields ...zap.Field)

Warn logs a warning message.

func With

func With(fields ...zap.Field) *zap.Logger

With creates a child logger with additional fields.

func WithComponent

func WithComponent(component string) *zap.Logger

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.

Jump to

Keyboard shortcuts

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