log

package
v0.0.0-...-ffb6c4e Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SecurityMark = "[Security Mark]"

Variables

View Source
var (

	// defined
	Skip        = zap.Skip
	Binary      = zap.Binary
	Bool        = zap.Bool
	Boolp       = zap.Boolp
	ByteString  = zap.ByteString
	Complex128  = zap.Complex128
	Complex128p = zap.Complex128p
	Complex64   = zap.Complex64
	Complex64p  = zap.Complex64p
	Float64     = zap.Float64
	Float64p    = zap.Float64p
	Float32     = zap.Float32
	Float32p    = zap.Float32p
	Int         = zap.Int
	Intp        = zap.Intp
	Int64       = zap.Int64
	Int64p      = zap.Int64p
	Int32       = zap.Int32
	Int32p      = zap.Int32p
	Int16       = zap.Int16
	Int16p      = zap.Int16p
	Int8        = zap.Int8
	Int8p       = zap.Int8p
	String      = zap.String
	Stringp     = zap.Stringp
	Uint        = zap.Uint
	Uintp       = zap.Uintp
	Uint64      = zap.Uint64
	Uint64p     = zap.Uint64p
	Uint32      = zap.Uint32
	Uint32p     = zap.Uint32p
	Uint16      = zap.Uint16
	Uint16p     = zap.Uint16p
	Uint8       = zap.Uint8
	Uint8p      = zap.Uint8p
	Uintptr     = zap.Uintptr
	Uintptrp    = zap.Uintptrp
	Reflect     = zap.Reflect
	Namespace   = zap.Namespace
	Stringer    = zap.Stringer
	Time        = zap.Time
	Timep       = zap.Timep
	Stack       = zap.Stack
	StackSkip   = zap.StackSkip
	Errors      = zap.Errors
	ErrorField  = zap.Error
	Duration    = zap.Duration
	Durationp   = zap.Durationp
	Any         = zap.Any

	WithCaller    = zap.WithCaller
	AddCallerSkip = zap.AddCallerSkip
	AddStacktrace = zap.AddStacktrace

	// core
	NewCore           = zapcore.NewCore
	NewNopCore        = zapcore.NewNopCore
	AddSync           = zapcore.AddSync
	NewJSONEncoder    = zapcore.NewJSONEncoder
	NewConsoleEncoder = zapcore.NewConsoleEncoder

	// encoder config
	NewDevelopmentEncoderConfig = zap.NewDevelopmentEncoderConfig
	NewProductionEncoderConfig  = zap.NewProductionEncoderConfig

	Named  = std.zaplog.Named
	Info   = std.zaplog.Info
	Warn   = std.zaplog.Warn
	Error  = std.zaplog.Error
	DPanic = std.zaplog.DPanic
	Panic  = std.zaplog.Panic
	Fatal  = std.zaplog.Fatal
	Debug  = std.zaplog.Debug
	Sugar  = std.zaplog.Sugar
	Debugf = std.zaplog.Sugar().Debugf
	Infof  = std.zaplog.Sugar().Infof
	Warnf  = std.zaplog.Sugar().Warnf
	Errorf = std.zaplog.Sugar().Errorf
	Fatalf = std.zaplog.Sugar().Fatalf
)

Functions

func ResetDefault

func ResetDefault(newStd *Logger)

func SetLevel

func SetLevel(level string)

func Sync

func Sync() error

func WithCtx

func WithCtx(ctx context.Context) *zap.Logger

func WithFields

func WithFields(ctx context.Context, fields ...Field) (context.Context, *zap.Logger)

Types

type Config

type Config = zap.Config

type Core

type Core = zapcore.Core

type EncodeType

type EncodeType = int
const (
	ConsoleEncoder EncodeType = iota // 0, default 控制台编码器
	JSONEncoder
)

type EncoderConfig

type EncoderConfig = zapcore.EncoderConfig

type Field

type Field = zap.Field

func StringSecurity

func StringSecurity(key string, v string) Field

type Key

type Key int

type Level

type Level = zapcore.Level
const (
	InfoLevel   Level = zap.InfoLevel   // 0, default level
	WarnLevel   Level = zap.WarnLevel   // 1
	ErrorLevel  Level = zap.ErrorLevel  // 2
	DPanicLevel Level = zap.DPanicLevel // 3, used in development log
	PanicLevel  Level = zap.PanicLevel  // 4, PanicLevel logs a message, then panics
	FatalLevel  Level = zap.FatalLevel  // 5, FatalLevel logs a message, then calls os.Exit(1).
	DebugLevel  Level = zap.DebugLevel  // -1
)

type LevelEnablerFunc

type LevelEnablerFunc func(lvl Level) bool

type Logger

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

func Default

func Default() *Logger

func New

func New(writer io.Writer, level Level, opts ...Option) *Logger

New create a new logger (not support log rotating).

func NewCustom

func NewCustom(core Core, opts ...Option) *Logger

NewCustom New Logger with any config

func NewNop

func NewNop() *Logger

NewNop New nil output Logger

func NewTeeWithRotate

func NewTeeWithRotate(tops []TeeOption, opts ...Option) *Logger

NewTeeWithRotate New Prod Logger and rotate logger files

func NewWithEncoder

func NewWithEncoder(writer io.Writer, level Level, encoder EncoderConfig, opts ...Option) *Logger

NewWithEncoder New Logger with custom EncoderConfig

func (*Logger) Sync

func (l *Logger) Sync() error

type Option

type Option = zap.Option

type RotateOptions

type RotateOptions struct {
	MaxSize    int
	MaxAge     int
	MaxBackups int
	Compress   bool
	LocalTime  bool
}

type TeeOption

type TeeOption struct {
	Filename string
	Ropt     RotateOptions
	Lef      LevelEnablerFunc
}

Jump to

Keyboard shortcuts

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