blog

package
v0.0.0-...-c113072 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugLevel = zapcore.DebugLevel
	InfoLevel  = zapcore.InfoLevel
	WarnLevel  = zapcore.WarnLevel
	ErrorLevel = zapcore.ErrorLevel
	PanicLevel = zapcore.PanicLevel
	FatalLevel = zapcore.FatalLevel
)

定义日志级别

View Source
var (
	Any         = zap.Any
	Array       = zap.Array
	Object      = zap.Object
	Binary      = zap.Binary
	Bool        = zap.Bool
	Bools       = zap.Bools
	ByteString  = zap.ByteString
	ByteStrings = zap.ByteStrings
	Complex64   = zap.Complex64
	Complex64s  = zap.Complex64s
	Complex128  = zap.Complex128
	Complex128s = zap.Complex128s
	Duration    = zap.Duration
	Durations   = zap.Durations
	Err         = zap.Error
	Errors      = zap.Errors
	Float32     = zap.Float32
	Float32s    = zap.Float32s
	Float64     = zap.Float64
	Float64s    = zap.Float64s
	Int         = zap.Int
	Ints        = zap.Ints
	Int8        = zap.Int8
	Int8s       = zap.Int8s
	Int16       = zap.Int16
	Int16s      = zap.Int16s
	Int32       = zap.Int32
	Int32s      = zap.Int32s
	Int64       = zap.Int64
	Int64s      = zap.Int64s
	Namespace   = zap.Namespace
	Reflect     = zap.Reflect
	Stack       = zap.Stack
	String      = zap.String
	Stringer    = zap.Stringer
	Strings     = zap.Strings
	Time        = zap.Time
	Times       = zap.Times
	Uint        = zap.Uint
	Uints       = zap.Uints
	Uint8       = zap.Uint8
	Uint8s      = zap.Uint8s
	Uint16      = zap.Uint16
	Uint16s     = zap.Uint16s
	Uint32      = zap.Uint32
	Uint32s     = zap.Uint32s
	Uint64      = zap.Uint64
	Uint64s     = zap.Uint64s
	Uintptr     = zap.Uintptr
	Uintptrs    = zap.Uintptrs
)

定义类型别名

Functions

func Debug

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

func Debugf

func Debugf(format string, v ...interface{})

func Debugw

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

func Error

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

func Errorf

func Errorf(format string, v ...interface{})

func Errorw

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

func Fatal

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

func Fatalf

func Fatalf(format string, v ...interface{})

func Fatalw

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

func Flush

func Flush()

func Info

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

func Infof

func Infof(format string, v ...interface{})

func Infow

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

func Init

func Init(opts *Options)

初始化全局log对象

func New

func New(opts *Options) *zapLogger

func Panic

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

func Panicf

func Panicf(format string, v ...interface{})

func Panicw

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

func SetStdLog

func SetStdLog(l *zapLogger)

func StdLogger

func StdLogger() *zapLogger

func Warn

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

func Warnf

func Warnf(format string, v ...interface{})

func Warnw

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

func WithValues

func WithValues(keysAndValues ...interface{})

添加一个固定字段到std logger中

func WrapOption

func WrapOption(opts *Options)

Types

type Field

type Field = zapcore.Field

type Level

type Level = zapcore.Level

type Logger

type Logger interface {
	Debug(msg string, fields ...Field)
	Debugf(format string, v ...interface{})
	Debugw(msg string, keysAndValues ...interface{})

	Warn(msg string, fields ...Field)
	Warnf(format string, v ...interface{})
	Warnw(msg string, keysAndValues ...interface{})

	Error(msg string, fields ...Field)
	Errorf(format string, v ...interface{})
	Errorw(msg string, keysAndValues ...interface{})

	Panic(msg string, fields ...Field)
	Panicf(format string, v ...interface{})
	Panicw(msg string, keysAndValues ...interface{})

	Fatal(msg string, fields ...Field)
	Fatalf(format string, v ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})

	// WithName adds a new element to the logger's name.
	// Successive calls with WithName continue to append
	// suffixes to the logger's name.  It's strongly recommended
	// that name segments contain only letters, digits, and hyphens
	// (see the package documentation for more information).
	WithName(name string) Logger

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

func WithName

func WithName(s string) Logger

给模块命名

type Options

type Options struct {
	// ErrorOutputPaths  []string `json:"error-output-paths" mapstructure:"error-output-paths"`
	OutputPath        string `json:"output-path"       mapstructure:"output-path"`
	Level             string `json:"level"              mapstructure:"level"`
	Format            string `json:"format"             mapstructure:"format"`
	TimeFormat        string `json:"time-format"        mapstructure:"time-format"`
	DisableCaller     bool   `json:"disable-caller"     mapstructure:"disable-caller"`
	DisableStacktrace bool   `json:"disable-stacktrace" mapstructure:"disable-stacktrace"`
	EnableColor       bool   `json:"enable-color"       mapstructure:"enable-color"`
	Development       bool   `json:"development"        mapstructure:"development"`
	ModuleName        string `json:"module-name"        mapstructure:"module-name"`
	MaxSize           int    `json:"max-size"           mapstructure:"max-size"`
	Name              string `json:"name"               mapstructure:"name"`
}

Options contains configuration items related to log.

func NewOptions

func NewOptions() *Options

创建一个默认的Options

func (*Options) Build

func (o *Options) Build() error

Build constructs a global zap logger from the Config and Options.

func (*Options) String

func (o *Options) String() string

func (*Options) Validate

func (o *Options) Validate() []error

Validate validate the options fields.

type Writer

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

func NewWriter

func NewWriter(path string, format string, n string, size int) *Writer

创建Writer path:文件的目录 format: 日期的格式化,请使用go起点日期2006-01-02 15:04:05 modulename: 模块名称

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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