log

package module
v1.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 6 Imported by: 0

README

log

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
	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
	Strings     = zap.Strings
	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
	Uintptrs    = zap.Uintptrs
	Time        = zap.Time
	Timep       = zap.Timep
	Times       = zap.Times
	Duration    = zap.Duration
	Durationp   = zap.Durationp
	Durations   = zap.Durations
	NamedError  = zap.NamedError
	Errors      = zap.Errors
	Stringer    = zap.Stringer
	Reflect     = zap.Reflect
	Any         = zap.Any
)
View Source
var (
	LowercaseLevelEncoder      = zapcore.LowercaseLevelEncoder
	LowercaseColorLevelEncoder = zapcore.LowercaseColorLevelEncoder
	CapitalLevelEncoder        = zapcore.CapitalLevelEncoder
	CapitalColorLevelEncoder   = zapcore.CapitalColorLevelEncoder
)

Level encoders to serialize levels

View Source
var (
	EpochTimeEncoder       = zapcore.EpochTimeEncoder
	EpochMillisTimeEncoder = zapcore.EpochMillisTimeEncoder
	EpochNanosTimeEncoder  = zapcore.EpochNanosTimeEncoder
	ISO8601TimeEncoder     = zapcore.ISO8601TimeEncoder
	RFC3339TimeEncoder     = zapcore.RFC3339TimeEncoder
	RFC3339NanoTimeEncoder = zapcore.RFC3339NanoTimeEncoder
)
View Source
var TimeEncoderOfLayout = zapcore.TimeEncoderOfLayout

create a time encoder from layouts

Functions

func NewFieldLog

func NewFieldLog(opt ...Option) *fieldLogger

New create a new field logger

Types

type Field

type Field = zap.Field

type Level

type Level = zapcore.Level
const (
	DEBUG  Level = zap.DebugLevel
	INFO   Level = zap.InfoLevel
	WARN   Level = zap.WarnLevel
	ERROR  Level = zap.ErrorLevel
	DPANIC Level = zap.DPanicLevel
	PANIC  Level = zap.PanicLevel
	FATAL  Level = zap.FatalLevel
)

type OUTPUT_FORMAT

type OUTPUT_FORMAT string
const (
	TextFormat OUTPUT_FORMAT = `text`
	JSONFormat OUTPUT_FORMAT = `json`
)

type Option

type Option func(*logOptions)

func WithColors

func WithColors(color bool) Option

WithStdOut sets the log writer.

func WithCtxTraceExtractor

func WithCtxTraceExtractor(fn func(ctx context.Context) string) Option

WithCtxTraceExtractor allows setting up of a function to extract trace from the context. Default value func(_ context.Context) string{return ""}

func WithFilePath

func WithFilePath(enabled bool) Option

WithFilePath sets whether the file path is logged or not.

func WithFuncPath

func WithFuncPath(enabled bool) Option

WithFuncPath sets whether the function name is logged or not.

func WithLevelEncoder

func WithLevelEncoder(enc func(Level, zapcore.PrimitiveArrayEncoder)) Option

func WithLogLevel

func WithLogLevel(lvl Level) Option
WithLogLevel sets the log level.

This would determine what types of logs would be logged based on the precedence of the log level

func WithName

func WithName(name string) Option

WithName sets a prefixed value to be logged

func WithOutputFormat

func WithOutputFormat(o OUTPUT_FORMAT) Option

WithOutput sets the output format for log entries. Either JSON or text based.

func WithSkipFrameCount

func WithSkipFrameCount(c int) Option

WithSkipFrameCount sets the frame count to skip when reading filepath, func path.

func WithStdOut

func WithStdOut(w io.Writer) Option

WithStdOut sets the log writer.

func WithTimeEncoder

func WithTimeEncoder(enc func(time.Time, zapcore.PrimitiveArrayEncoder)) Option

Jump to

Keyboard shortcuts

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