log

package
v1.29.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FatalLevel = zap.FatalLevel
	ErrorLevel = zap.ErrorLevel
	WarnLevel  = zap.WarnLevel
	InfoLevel  = zap.InfoLevel
	DebugLevel = zap.DebugLevel
)

Variables

This section is empty.

Functions

func StdLoggerWithLevel added in v1.24.0

func StdLoggerWithLevel(adapter Logger, level Level, withFields ...Field) *log.Logger

func ToContext

func ToContext(ctx context.Context, kvs ...Field) context.Context

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Adapter, error)

func NewFromConfig added in v1.27.0

func NewFromConfig(config Config) (*Adapter, error)

func (*Adapter) Config added in v1.29.0

func (a *Adapter) Config() Config

func (*Adapter) Debug

func (a *Adapter) Debug(ctx context.Context, message any, fields ...Field)

func (*Adapter) Enabled added in v1.4.0

func (a *Adapter) Enabled(level Level) bool

func (*Adapter) Error

func (a *Adapter) Error(ctx context.Context, message any, fields ...Field)

func (*Adapter) Fatal

func (a *Adapter) Fatal(ctx context.Context, message any, fields ...Field)

func (*Adapter) Info

func (a *Adapter) Info(ctx context.Context, message any, fields ...Field)

func (*Adapter) Log

func (a *Adapter) Log(ctx context.Context, level Level, message any, fields ...Field)

func (*Adapter) SetLevel

func (a *Adapter) SetLevel(level Level)

func (*Adapter) Sync added in v1.25.0

func (a *Adapter) Sync() error

func (*Adapter) Warn added in v1.24.0

func (a *Adapter) Warn(ctx context.Context, message any, fields ...Field)

type Config added in v1.27.0

type Config struct {
	IsInDevMode  bool
	OutputPaths  []string
	Sampling     *SamplingConfig
	Hooks        []func(entry zapcore.Entry) error
	InitialLevel Level
}

func DefaultConfig added in v1.27.0

func DefaultConfig() *Config

type Field

type Field = zap.Field

func Any

func Any(key string, value any) Field

func Bool

func Bool(key string, value bool) Field

func ByteString

func ByteString(key string, value []byte) Field

func ContextLogValues

func ContextLogValues(ctx context.Context) []Field

func Int

func Int(key string, value int) Field

func Int32

func Int32(key string, value int32) Field

func Int64

func Int64(key string, value int64) Field

func String

func String(key string, value string) Field

type Level

type Level = zapcore.Level

type Logger

type Logger interface {
	Error(ctx context.Context, message any, fields ...Field)
	Warn(ctx context.Context, message any, fields ...Field)
	Info(ctx context.Context, message any, fields ...Field)
	Debug(ctx context.Context, message any, fields ...Field)
}

type Option

type Option func(cfg *Config)

func WithDevelopmentMode

func WithDevelopmentMode() Option

func WithFileOutput added in v1.27.0

func WithFileOutput(fileOutput file.Output) Option

func WithLevel

func WithLevel(level Level) Option

type SamplingConfig added in v1.27.0

type SamplingConfig = zap.SamplingConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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