log

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	EncoderConsole = "console"
	EncoderJson    = "json"
)

Variables

This section is empty.

Functions

func CtxDebugw

func CtxDebugw(ctx context.Context, msg string, keysAndValues ...interface{})

CtxDebugw ...

func CtxErrorw

func CtxErrorw(ctx context.Context, msg string, keysAndValues ...interface{})

CtxErrorw ...

func CtxFatalw

func CtxFatalw(ctx context.Context, msg string, keysAndValues ...interface{})

CtxFatalw ...

func CtxInfow

func CtxInfow(ctx context.Context, msg string, keysAndValues ...interface{})

CtxInfow ...

func CtxPanicw

func CtxPanicw(ctx context.Context, msg string, keysAndValues ...interface{})

CtxPanicw ...

func CtxWarnw

func CtxWarnw(ctx context.Context, msg string, keysAndValues ...interface{})

CtxWarnw ...

func Debugw

func Debugw(msg string, keysAndValues ...interface{})

Debugw ...

func Errorw

func Errorw(msg string, keysAndValues ...interface{})

Errorw ...

func Fatalw

func Fatalw(msg string, keysAndValues ...interface{})

Fatalw ...

func GetZapLogger

func GetZapLogger() *zap.Logger

GetZapLogger ...

func Infow

func Infow(msg string, keysAndValues ...interface{})

Infow ...

func Panicw

func Panicw(msg string, keysAndValues ...interface{})

Panicw ...

func RegisterLogger

func RegisterLogger(options *Options)

RegisterLogger register global logger.

func Sync

func Sync()

Sync ...

func Warnw

func Warnw(msg string, keysAndValues ...interface{})

Warnw ...

Types

type Logger

type Logger interface {
	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})

	CtxDebugw(ctx context.Context, template string, args ...interface{})
	CtxInfow(ctx context.Context, template string, args ...interface{})
	CtxWarnw(ctx context.Context, template string, args ...interface{})
	CtxErrorw(ctx context.Context, template string, args ...interface{})
	CtxPanicw(ctx context.Context, template string, args ...interface{})
	CtxFatalw(ctx context.Context, template string, args ...interface{})

	Sync()
}

Logger ...

func NewLogger

func NewLogger(opts *Options) Logger

NewLogger new a logger.

type Options

type Options struct {
	Level       string   `mapstructure:"level"`
	OutputPath  string   `mapstructure:"output-path,omitempty"`
	EncoderType string   `mapstructure:"encoder-type,omitempty"`
	MaxSize     int      `mapstructure:"max-size,omitempty"`
	MaxBackups  int      `mapstructure:"max-backups,omitempty"`
	MaxAge      int      `mapstructure:"max-age,omitempty"`
	Compress    bool     `mapstructure:"compress,omitempty"`
	MessageKey  string   `mapstructure:"message-key,omitempty"`
	LevelKey    string   `mapstructure:"level-key,omitempty"`
	CallerKey   string   `mapstructure:"caller-key,omitempty"`
	TimeKey     string   `mapstructure:"time-key,omitempty"`
	ExtraKeys   []string `mapstructure:"extra-keys,omitempty"`
}

Options ...

func NewOptions

func NewOptions() *Options

NewOptions new a log option.

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

AddFlags ...

func (*Options) Validate

func (o *Options) Validate() error

Validate validate log options is valid.

Jump to

Keyboard shortcuts

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