log

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	Debug:         false,
	LogLevel:      "info",
	AppName:       "changeme",
	AppID:         "changeme",
	Version:       "0.0.1",
	Revision:      "123456789",
	DisableFields: false,
}

DefaultOptions defines default logger options

Functions

func Any

func Any(key string, value interface{}) zapcore.Field

Any type wrapper

func Array

func Array(key string, val zapcore.ArrayMarshaler) zapcore.Field

Array type wrapper

func Binary

func Binary(key string, val []byte) zapcore.Field

Binary type wrapper

func Bool

func Bool(key string, val bool) zapcore.Field

Bool type wrapper

func Bools

func Bools(key string, bs []bool) zapcore.Field

Bools type wrapper

func ByteString

func ByteString(key string, val []byte) zapcore.Field

ByteString type wrapper

func ByteStrings

func ByteStrings(key string, bss [][]byte) zapcore.Field

ByteStrings type wrapper

func CheckErr

func CheckErr(msg string, err error, fields ...zapcore.Field)

CheckErr handles error correctly

func CheckErrCtx

func CheckErrCtx(ctx context.Context, msg string, err error, fields ...zapcore.Field)

CheckErrCtx handles error correctly

func Complex128

func Complex128(key string, val complex128) zapcore.Field

Complex128 type wrapper

func Complex128s

func Complex128s(key string, nums []complex128) zapcore.Field

Complex128s type wrapper

func Complex64

func Complex64(key string, val complex64) zapcore.Field

Complex64 type wrapper

func Complex64s

func Complex64s(key string, nums []complex64) zapcore.Field

Complex64s type wrapper

func Duration

func Duration(key string, val time.Duration) zapcore.Field

Duration type wrapper

func Durations

func Durations(key string, ds []time.Duration) zapcore.Field

Durations type wrapper

func Error

func Error(err error) zapcore.Field

Error type wrapper

func Errors

func Errors(key string, errs []error) zapcore.Field

Errors type wrapper

func Float32

func Float32(key string, val float32) zapcore.Field

Float32 type wrapper

func Float32s

func Float32s(key string, nums []float32) zapcore.Field

Float32s type wrapper

func Float64

func Float64(key string, val float64) zapcore.Field

Float64 type wrapper

func Float64s

func Float64s(key string, nums []float64) zapcore.Field

Float64s type wrapper

func Int

func Int(key string, val int) zapcore.Field

Int type wrapper

func Int16

func Int16(key string, val int16) zapcore.Field

Int16 type wrapper

func Int16s

func Int16s(key string, nums []int16) zapcore.Field

Int16s type wrapper

func Int32

func Int32(key string, val int32) zapcore.Field

Int32 type wrapper

func Int32s

func Int32s(key string, nums []int32) zapcore.Field

Int32s type wrapper

func Int64

func Int64(key string, val int64) zapcore.Field

Int64 type wrapper

func Int64s

func Int64s(key string, nums []int64) zapcore.Field

Int64s type wrapper

func Int8

func Int8(key string, val int8) zapcore.Field

Int8 type wrapper

func Int8s

func Int8s(key string, nums []int8) zapcore.Field

Int8s type wrapper

func Ints

func Ints(key string, nums []int) zapcore.Field

Ints type wrapper

func NamedError

func NamedError(key string, err error) zapcore.Field

NamedError type wrapper

func Namespace

func Namespace(key string) zapcore.Field

Namespace type wrapper

func Object

func Object(key string, val zapcore.ObjectMarshaler) zapcore.Field

Object type wrapper

func Reflect

func Reflect(key string, val interface{}) zapcore.Field

Reflect type wrapper

func SafeClose

func SafeClose(c io.Closer, msg string, fields ...zapcore.Field)

SafeClose handles the closer error

func SafeCloseCtx

func SafeCloseCtx(ctx context.Context, c io.Closer, msg string, fields ...zapcore.Field)

SafeCloseCtx handles the closer error

func SetLoggerFactory

func SetLoggerFactory(instance LoggerFactory)

SetLoggerFactory defines the default package logger

func Setup

func Setup(ctx context.Context, opts Options) zap.AtomicLevel

Setup the logger return atomicLevel for thread-safe log level change

func Skip

func Skip() zapcore.Field

Skip type wrapper

func Stack

func Stack(key string) zapcore.Field

Stack type wrapper

func String

func String(key string, val string) zapcore.Field

String type wrapper

func Stringer

func Stringer(key string, val fmt.Stringer) zapcore.Field

Stringer type wrapper

func Strings

func Strings(key string, ss []string) zapcore.Field

Strings type wrapper

func Time

func Time(key string, val time.Time) zapcore.Field

Time type wrapper

func Times

func Times(key string, ts []time.Time) zapcore.Field

Times type wrapper

func Uint

func Uint(key string, val uint) zapcore.Field

Uint type wrapper

func Uint16

func Uint16(key string, val uint16) zapcore.Field

Uint16 type wrapper

func Uint16s

func Uint16s(key string, nums []uint16) zapcore.Field

Uint16s type wrapper

func Uint32

func Uint32(key string, val uint32) zapcore.Field

Uint32 type wrapper

func Uint32s

func Uint32s(key string, nums []uint32) zapcore.Field

Uint32s type wrapper

func Uint64

func Uint64(key string, val uint64) zapcore.Field

Uint64 type wrapper

func Uint64s

func Uint64s(key string, nums []uint64) zapcore.Field

Uint64s type wrapper

func Uint8

func Uint8(key string, val uint8) zapcore.Field

Uint8 type wrapper

func Uint8s

func Uint8s(key string, nums []uint8) zapcore.Field

Uint8s type wrapper

func Uintptr

func Uintptr(key string, val uintptr) zapcore.Field

Uintptr type wrapper

func Uintptrs

func Uintptrs(key string, us []uintptr) zapcore.Field

Uintptrs type wrapper

func Uints

func Uints(key string, nums []uint) zapcore.Field

Uints type wrapper

Types

type Logger

type Logger interface {
	Debug(msg string, fields ...zapcore.Field)
	Info(msg string, fields ...zapcore.Field)
	Warn(msg string, fields ...zapcore.Field)
	Error(msg string, fields ...zapcore.Field)
	Fatal(msg string, fields ...zapcore.Field)
	With(fields ...zapcore.Field) Logger

	Debugf(msg string, args ...interface{})
	Infof(msg string, args ...interface{})
	Warnf(msg string, args ...interface{})
	Errorf(msg string, args ...interface{})
	Fatalf(msg string, args ...interface{})
}

Logger is a simplified abstraction of the zap.Logger

func Bg

func Bg() Logger

Bg delegates a no-context logger

func For

func For(ctx context.Context) Logger

For delegates a context logger

type LoggerFactory

type LoggerFactory interface {
	Name() string
	Bg() Logger
	For(context.Context) Logger
	With(...zapcore.Field) LoggerFactory
}

LoggerFactory defines logger factory contract

func Default

func Default() LoggerFactory

Default returns the logger factory

func NewFactory

func NewFactory(logger *zap.Logger) LoggerFactory

NewFactory creates a new Factory.

type Options

type Options struct {
	LogLevel      string
	AppName       string
	AppID         string
	Version       string
	Revision      string
	Debug         bool
	DisableFields bool
}

Options declares logger options for builder

Jump to

Keyboard shortcuts

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