xlog_config

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zapcore.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zapcore.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zapcore.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = zapcore.ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = zapcore.DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zapcore.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zapcore.FatalLevel
)

Variables

This section is empty.

Functions

func InitFromConfig

func InitFromConfig(conf Config, opts ...Option) (err error)

func InitFromJson

func InitFromJson(conf []byte, opts ...Option) (err error)

func InitFromOption

func InitFromOption(opts ...Option) (err error)

func NewFromConfig

func NewFromConfig(conf Config, opts ...Option) (_ internal.XLog, err error)

func NewFromJson

func NewFromJson(conf []byte, opts ...Option) (_ internal.XLog, err error)

func NewFromOption

func NewFromOption(opts ...Option) (_ internal.XLog, err error)

Types

type Config

type Config config

func NewDevConfig

func NewDevConfig() Config

func NewProdConfig

func NewProdConfig() Config

type Level

type Level = zapcore.Level

type Option

type Option func(opts *config)

func WithCaller

func WithCaller() Option

AddCaller configures the Logger to annotate each message with the filename and line number of zap's caller.

func WithCallerSkip

func WithCallerSkip(skip int) Option

AddCallerSkip increases the number of callers skipped by caller annotation (as enabled by the AddCaller option). When building wrappers around the Logger and SugaredLogger, supplying this Option prevents zap from always reporting the wrapper code as the caller.

func WithDevelopment

func WithDevelopment() Option

Development puts the logger in development mode, which makes DPanic-level logs panic instead of simply logging an error.

func WithEncoding

func WithEncoding(enc string) Option

WithEncoding ...

func WithErrorOutput

func WithErrorOutput(w zapcore.WriteSyncer) Option

ErrorOutput sets the destination for errors generated by the Logger. Note that this option only affects internal errors; for sample code that sends error-level logs to a different location from info- and debug-level logs, see the package-level AdvancedConfiguration example.

The supplied WriteSyncer must be safe for concurrent use. The Open and zapcore.Lock functions are the simplest ways to protect files with a mutex.

func WithFields

func WithFields(fs ...zap.Field) Option

Fields adds fields to the Logger.

func WithHooks

func WithHooks(hooks ...func(zapcore.Entry) error) Option

Hooks registers functions which will be called each time the Logger writes out an Entry. Repeated use of Hooks is additive.

Hooks are useful for simple side effects, like capturing metrics for the number of emitted logs. More complex side effects, including anything that requires access to the Entry's structured fields, should be implemented as a zapcore.Core instead. See zapcore.RegisterHooks for details.

func WithLevel

func WithLevel(ll Level) Option

func WithStacktrace

func WithStacktrace(lvl zapcore.LevelEnabler) Option

AddStacktrace configures the Logger to record a stack trace for all messages at or above a given level.

Jump to

Keyboard shortcuts

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