zlog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	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
	Duration    = zap.Duration
	Durationp   = zap.Durationp
	Any         = zap.Any
)

Zlog Field Definition

View Source
var (
	Info   = std.Info
	Warn   = std.Warn
	Error  = std.Error
	DPanic = std.DPanic
	Fatal  = std.Fatal
	Debug  = std.Debug
)

Logger function alias

View Source
var (
	WithCaller = zap.WithCaller
	WithTrace  = zap.AddStacktrace
)

Logger Option

View Source
var DefaultRotation = func(filename string) Rotation {
	return Rotation{
		Filename:   filename,
		MaxSize:    2 << 10,
		MaxAge:     7,
		MaxBackups: 5,
		Compress:   true,
		LocalTime:  true,
	}
}

DefaultRotation with default rotate option. MaxSize: 2GB MaxBackups: 5 MaxAge: 7 days

View Source
var Sugar = std.Sugar

Sugar for std logger

Functions

func ColoredCapitalLevelEncoder

func ColoredCapitalLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

ColoredCapitalLevelEncoder for colored capital level

func ColoredShortCallerEncoder

func ColoredShortCallerEncoder(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder)

ColoredShortCallerEncoder for colored shortCallerEncoder

func ColoredTimeEncoder

func ColoredTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

ColoredTimeEncoder custom encoder for time field

func ColoredTimeEncoderWithLayout

func ColoredTimeEncoderWithLayout(layout string) zapcore.TimeEncoder

ColoredTimeEncoderWithLayout custom encoder for time field with a layout

func Default

func Default() *zap.Logger

Default create a default logger

func New

func New() *zap.Logger

New create a logger instance

func NewColoredConsoleEncoder

func NewColoredConsoleEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

NewColoredConsoleEncoder create ColoredConsoleEncoder instance

func NewRotateLogger

func NewRotateLogger(tops []TeeOption, ops ...Option) *zap.Logger

NewRotateLogger create rotate logger instance

func RegisterColorConsoleEncoder

func RegisterColorConsoleEncoder()

RegisterColorConsoleEncoder register an encoder constructor for zapcore

func ResetDefault

func ResetDefault(l *zap.Logger)

ResetDefault replace default logger

func Sync

func Sync() error

Sync flushing buffered log of standard logger

Types

type Color

type Color uint8

Color represents a text color.

const (
	Black Color = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White
)

Terminal Colors

func (Color) Add

func (c Color) Add(s string) string

Add adds the color to the given string

func (Color) Any

func (c Color) Any(s interface{}) string

Any adds the color to any type

func (Color) Bold

func (c Color) Bold(s string) string

Bold adds a bold color to the given string

type ColoredConsoleEncoder

type ColoredConsoleEncoder struct {
	*zapcore.EncoderConfig
	zapcore.Encoder
}

ColoredConsoleEncoder encode logger entry with color

func (ColoredConsoleEncoder) EncodeEntry

func (c ColoredConsoleEncoder) EncodeEntry(
	entry zapcore.Entry, fields []zapcore.Field) (*buffer.Buffer, error)

EncodeEntry encode each log field

type Field

type Field = zap.Field

Field is an alias for zlog Field

type Level

type Level = zapcore.Level

Level zlog logger level

const (
	DebugLevel  Level = zap.DebugLevel
	InfoLevel   Level = zap.InfoLevel
	WarnLevel   Level = zap.WarnLevel
	ErrorLevel  Level = zap.ErrorLevel
	DPanicLevel Level = zap.DPanicLevel
	PanicLevel  Level = zap.PanicLevel
	FatalLevel  Level = zap.PanicLevel
)

Zlog Logger Level

type LevelEnablerFunc

type LevelEnablerFunc = zap.LevelEnablerFunc

LevelEnablerFunc implement LevelEnabler

type Option

type Option = zap.Option

Option configures a Logger

type Rotation

type Rotation = lumberjack.Logger

Rotation option for logger rotate

type TeeOption

type TeeOption struct {
	Rotation  Rotation
	LevelFunc LevelEnablerFunc
}

TeeOption for writer syncer

Jump to

Keyboard shortcuts

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