xlog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 5 Imported by: 0

README

xlog

Documentation

Index

Constants

View Source
const (
	// DebugLevel alias for zapcore.DebugLevel
	DebugLevel = zap.DebugLevel
	// InfoLevel alias for zapcore.InfoLevel
	InfoLevel = zap.InfoLevel
	// WarnLevel alias for zapcore.WarnLevel
	WarnLevel = zap.WarnLevel
	// ErrorLevel alias for zapcore.ErrorLevel
	ErrorLevel = zap.ErrorLevel
	// DPanicLevel alias for zapcore.DPanicLevel
	DPanicLevel = zapcore.DPanicLevel
	// PanicLevel alias for zapcore.PanicLevel
	PanicLevel = zap.PanicLevel
	// FatalLevel alias for zapcore.FatalLevel
	FatalLevel = zap.FatalLevel
)

Variables

View Source
var (
	// Skip alias for zap.Skip()
	Skip = zap.Skip()
	// Binary alias for zap.Binary
	Binary = zap.Binary
	// Bool alias for zap.Bool
	Bool = zap.Bool
	// Boolp alias for zap.Boolp
	Boolp = zap.Boolp
	// ByteString alias for zap.ByteString
	ByteString = zap.ByteString
	// Complex128 alias for zap.Complex128
	Complex128 = zap.Complex128
	// Complex128p alias for zap.Complex128p
	Complex128p = zap.Complex128p
	// Complex64 alias for zap.Complex64
	Complex64 = zap.Complex64
	// Complex64p alias for zap.Complex64p
	Complex64p = zap.Complex64p
	// Float64 alias for zap.Float64
	Float64 = zap.Float64
	// Float64p alias for zap.Float64p
	Float64p = zap.Float64p
	// Float32 alias for zap.Float32
	Float32 = zap.Float32
	// Float32p alias for zap.Float32p
	Float32p = zap.Float32p
	// Int alias for zap.Int
	Int = zap.Int
	// Intp alias for zap.Intp
	Intp = zap.Intp
	// Int64 alias for zap.Int64
	Int64 = zap.Int64
	// Int64p alias for zap.Int64p
	Int64p = zap.Int64p
	// Int32 alias for zap.Int32
	Int32 = zap.Int32
	// Int32p alias for zap.Int32p
	Int32p = zap.Int32p
	// Int16 alias for zap.Int16
	Int16 = zap.Int16
	// Int16p alias for zap.Int16p
	Int16p = zap.Int16p
	// Int8 alias for zap.Int8
	Int8 = zap.Int8
	// Int8p alias for zap.Int8p
	Int8p = zap.Int8p
	// String alias for zap.String
	String = zap.String
	// Stringp alias for zap.Stringp
	Stringp = zap.Stringp
	// Uint alias for zap.Uint
	Uint = zap.Uint
	// Uintp alias for zap.Uintp
	Uintp = zap.Uintp
	// Uint64 alias for zap.Uint64
	Uint64 = zap.Uint64
	// Uint64p alias for zap.Uint64p
	Uint64p = zap.Uint64p
	// Uint32 alias for zap.Uint32
	Uint32 = zap.Uint32
	// Uint32p alias for zap.Uint32p
	Uint32p = zap.Uint32p
	// Uint16 alias for zap.Uint16
	Uint16 = zap.Uint16
	// Uint16p alias for zap.Uint16p
	Uint16p = zap.Uint16p
	// Uint8 alias for zap.Uint8
	Uint8 = zap.Uint8
	// Uint8p alias for zap.Uint8p
	Uint8p = zap.Uint8p
	// Uintptr alias for zap.Uintptr
	Uintptr = zap.Uintptr
	// Uintptrp alias for zap.Uintptrp
	Uintptrp = zap.Uintptrp
	// Reflect alias for zap.Reflect
	Reflect = zap.Reflect
	// Namespace alias for zap.Namespace
	Namespace = zap.Namespace
	// Stringer alias for zap.Stringer
	Stringer = zap.Stringer
	// Time alias for zap.Time
	Time = zap.Time
	// Timep alias for zap.Timep
	Timep = zap.Timep
	// Stack alias for zap.Stack
	Stack = zap.Stack
	// StackSkip alias for zap.StackSkip
	StackSkip = zap.StackSkip
	// Duration alias for zap.Duration
	Duration = zap.Duration
	// Durationp alias for zap.Duration
	Durationp = zap.Durationp
	// Object alias for zap.Object
	Object = zap.Object
	// Inline alias for zap.Inline
	Inline = zap.Inline
	// Any alias for zap.Any
	Any = zap.Any
)
View Source
var (
	// AddCallerSkip alias for zap.AddCallerSkip
	AddCallerSkip = zap.AddCallerSkip
)
View Source
var NamedError = zap.NamedError

NamedError alias for zap.NamedError

Functions

func Check

func Check(lvl Level, msg string) *zapcore.CheckedEntry

Check returns a CheckedEntry if logging a message at the specified level is enabled. It's a completely optional optimization; in high-performance applications, Check can help avoid allocating a slice to hold fields.

func Core

func Core() zapcore.Core

Core returns the Logger's underlying zapcore.Core.

func DPanic

func DPanic(msg string, fields ...Field)

DPanic logs a message at DPanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

If the logger is in development mode, it then panics (DPanic means "development panic"). This is useful for catching errors that are recoverable, but shouldn't ever happen.

func Debug

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

Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Error

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

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Fatal

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

Fatal logs a message at FatalLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.

func Info

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

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func Panic

func Panic(msg string, fields ...Field)

Panic logs a message at PanicLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

The logger then panics, even if logging at PanicLevel is disabled.

func SetLogger

func SetLogger(logger *Logger)

func Sugar

func Sugar() *zap.SugaredLogger

Sugar wraps the Logger to provide a more ergonomic, but slightly slower, API. Sugaring a Logger is quite inexpensive, so it's reasonable for a single application to use both Loggers and SugaredLoggers, converting between them on the boundaries of performance-sensitive code.

func Sync

func Sync() error

Sync calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.

func Warn

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

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

Types

type Config

type Config struct {
	Debug           bool   `mapstructure:"debug"`              // 是否双写至文件控制日志输出到终端
	Level           string `mapstructure:"level"`              // 日志初始等级,默认info级别
	EnableAddCaller bool   `mapsttructure:"enable_add_caller"` // 是否添加调用者信息,默认不加调用者信息
	Writer          string `mapstructure:"writer"`             // 使用哪种Writer,可选[file|stdout],默认stdout
	CallerSkip      int    `mapstructure:"caller_skip"`        // CallerSkip

	Fields        []zap.Field            // zapFields
	EncoderConfig *zapcore.EncoderConfig // 格式化配置
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) AtomicLevel

func (c *Config) AtomicLevel() zap.AtomicLevel

type Container

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

Container 容器

func DefaultContainer

func DefaultContainer() *Container

DefaultContainer 默认容器

func Load

func Load(key string) *Container

Load 加载配置key

func (*Container) Build

func (c *Container) Build(options ...Option) (*Logger, error)

Build 构建组件

type Field

type Field = zap.Field

Field alias for zap.Field

type Level

type Level = zapcore.Level

Level ...

type Logger

type Logger = zap.Logger

Logger ...

func GetLogger

func GetLogger() *Logger

func Named

func Named(s string) *Logger

Named adds a new path segment to the logger's name. Segments are joined by periods. By default, Loggers are unnamed.

func With

func With(fields ...Field) *Logger

With creates a child logger and adds structured context to it. Fields added to the child don't affect the parent, and vice versa.

func WithOptions

func WithOptions(opts ...zap.Option) *Logger

WithOptions clones the current Logger, applies the supplied Options, and returns the resulting Logger. It's safe to use concurrently.

type Option

type Option func(c *Container)

Option 可选项

func WithDebug

func WithDebug(debug bool) Option

WithDebug 设置在命令行显示

func WithEnableAddCaller

func WithEnableAddCaller(enableAddCaller bool) Option

WithEnableAddCaller 是否添加行号,默认不添加行号

func WithLevel

func WithLevel(level string) Option

WithLevel 设置级别

type SugaredLogger

type SugaredLogger = zap.SugaredLogger

SugaredLogger ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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