log

package
v1.38.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2024 License: MIT Imports: 7 Imported by: 4

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 RewriteContextField added in v1.33.0

func RewriteContextField(ctx context.Context, field Field) context.Context

func StdLoggerWithLevel

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

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

func (*Adapter) Config

func (a *Adapter) Config() Config

func (*Adapter) Debug

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

func (*Adapter) Enabled

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

func (a *Adapter) Sync() error

func (*Adapter) Warn

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

type Config

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

func DefaultConfig

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

func WithFileOutput(fileOutput file.Output) Option

func WithLevel

func WithLevel(level Level) Option

type SamplingConfig

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