logging

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package logging provides a structured logging system based on zap. It supports configurable log levels and output formats (JSON/text).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any

func Any(key string, value interface{}) zap.Field

Any creates a field with any value (uses reflection).

func Debug

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

Debug logs a message at DebugLevel with structured fields.

func Debugf

func Debugf(template string, args ...interface{})

Debugf logs a formatted message at DebugLevel.

func Duration

func Duration(key string, value interface{}) zap.Field

Duration creates a duration field.

func Err

func Err(err error) zap.Field

Err creates an error field with key "error".

func Error

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

Error logs a message at ErrorLevel with structured fields.

func Errorf

func Errorf(template string, args ...interface{})

Errorf logs a formatted message at ErrorLevel.

func Fatal

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

Fatal logs a message at FatalLevel with structured fields, then calls os.Exit(1).

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf logs a formatted message at FatalLevel, then calls os.Exit(1).

func Info

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

Info logs a message at InfoLevel with structured fields.

func Infof

func Infof(template string, args ...interface{})

Infof logs a formatted message at InfoLevel.

func Init

func Init(cfg *Config) error

Init initializes the logging system with the given configuration. It should be called early in the application startup.

func Int

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

Int creates an int field.

func Int64

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

Int64 creates an int64 field.

func L

func L() *zap.Logger

L returns the underlying zap.Logger for advanced usage.

func S

func S() *zap.SugaredLogger

S returns the underlying zap.SugaredLogger for advanced usage.

func String

func String(key, value string) zap.Field

String creates a string field.

func Sync

func Sync() error

Sync flushes any buffered log entries. Should be called before the application exits.

func Warn

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

Warn logs a message at WarnLevel with structured fields.

func Warnf

func Warnf(template string, args ...interface{})

Warnf logs a formatted message at WarnLevel.

Types

type Config

type Config struct {
	Level  string // debug, info, warn, error
	Format string // json, text
}

Config holds logging configuration.

Jump to

Keyboard shortcuts

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