log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 19 Imported by: 29

Documentation

Index

Constants

View Source
const (
	// ContextHeaderName opentracing log key is trace.traceid
	ContextHeaderName = iota
	TraceIdKey        = "traceid"
	SpanIdKey         = "spanid"
)

Variables

This section is empty.

Functions

func DPanic

func DPanic(args ...interface{})

func DPanicf

func DPanicf(template string, args ...interface{})

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses fmt.Sprintf to log a templated message.

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(template string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func NewContext

func NewContext(ctx context.Context, fields ...zapcore.Field) context.Context

NewContext creates a new context the given contextual fields

func NewTextEncoder

func NewTextEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

func Operator

func Operator() *zap.Logger

Operator return the structured logger

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})
func PrintLogo()

func StdPrintf

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

func StdPrintln

func StdPrintln(v ...interface{})

StdPrintln use native log.Println

func TraceIdField

func TraceIdField(ctx context.Context) zap.Field

TraceIdField get trace id of zap field type

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

Types

type Config

type Config struct {
	Tee    []zap.Config       `json:"tee" yaml:"tee"`
	Sole   *zap.Config        `json:"sole" yaml:"sole"`
	Rotate *lumberjack.Logger `json:"rotate" yaml:"rotate"`
	// contains filtered or unexported fields
}

Config is logger schema Tee use as zap advance,such as zapcore.NewTee() Sole use as one zap logger core

func NewConfig

func NewConfig(cfg *conf.Configuration) (*Config, error)

NewConfig return a Config instance

func (*Config) BuildZap

func (c *Config) BuildZap(opts ...zap.Option) (zl *zap.Logger, err error)

BuildZap build a zap.Logger by Config

type Logger

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

Logger integrate the Uber Zap library to use in woocoo

if you prefer to golang builtin log style,use log.Info or log.Infof, if zap style,you should use log.Operator().Info()

func Global

func Global() *Logger

func New

func New(zl *zap.Logger) (*Logger, error)

New return an Instance

func NewBuiltIn

func NewBuiltIn() *Logger

NewBuiltIn create a logger by configuration

func WithContext

func WithContext(ctx context.Context) *Logger

WithContext returns a logger from the given context

func (*Logger) Apply

func (l *Logger) Apply(cfg *conf.Configuration, path string)

Apply implement Configurable interface which can initial from a file used in JSON,YAML Logger init trough Apply method will be set as Global.

func (Logger) AsGlobal

func (l Logger) AsGlobal()

func (*Logger) DPanic

func (l *Logger) DPanic(msg string, fields ...zap.Field)

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...zap.Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...zap.Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...zap.Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...zap.Field)

func (Logger) Operator

func (l Logger) Operator() *zap.Logger

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...zap.Field)

func (*Logger) Sync

func (l *Logger) Sync() error

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

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...zap.Field)

func (*Logger) With

func (l *Logger) With(fields ...zapcore.Field) *Logger

type TextEncoder

type TextEncoder struct {
	*zapcore.EncoderConfig
	// contains filtered or unexported fields
}

func (*TextEncoder) AddArray

func (enc *TextEncoder) AddArray(key string, marshaler zapcore.ArrayMarshaler) (err error)

Logging-specific marshalers.

func (*TextEncoder) AddBinary

func (enc *TextEncoder) AddBinary(key string, value []byte)

Built-in types. for arbitrary bytes

func (*TextEncoder) AddBool

func (enc *TextEncoder) AddBool(key string, value bool)

func (*TextEncoder) AddByteString

func (enc *TextEncoder) AddByteString(key string, value []byte)

func (*TextEncoder) AddComplex128

func (enc *TextEncoder) AddComplex128(key string, value complex128)

func (*TextEncoder) AddComplex64

func (enc *TextEncoder) AddComplex64(key string, value complex64)

func (*TextEncoder) AddDuration

func (enc *TextEncoder) AddDuration(key string, value time.Duration)

func (*TextEncoder) AddFloat32

func (enc *TextEncoder) AddFloat32(key string, value float32)

func (*TextEncoder) AddFloat64

func (enc *TextEncoder) AddFloat64(key string, value float64)

func (*TextEncoder) AddInt

func (enc *TextEncoder) AddInt(key string, value int)

func (*TextEncoder) AddInt16

func (enc *TextEncoder) AddInt16(key string, value int16)

func (*TextEncoder) AddInt32

func (enc *TextEncoder) AddInt32(key string, value int32)

func (*TextEncoder) AddInt64

func (enc *TextEncoder) AddInt64(key string, value int64)

func (*TextEncoder) AddInt8

func (enc *TextEncoder) AddInt8(key string, value int8)

func (*TextEncoder) AddObject

func (enc *TextEncoder) AddObject(key string, marshaler zapcore.ObjectMarshaler) (err error)

func (*TextEncoder) AddReflected

func (enc *TextEncoder) AddReflected(key string, value interface{}) (err error)

AddReflected uses reflection to serialize arbitrary objects, so it can be slow and allocation-heavy.

func (*TextEncoder) AddString

func (enc *TextEncoder) AddString(key, value string)

func (*TextEncoder) AddTime

func (enc *TextEncoder) AddTime(key string, value time.Time)

func (*TextEncoder) AddUint

func (enc *TextEncoder) AddUint(key string, value uint)

func (*TextEncoder) AddUint16

func (enc *TextEncoder) AddUint16(key string, value uint16)

func (*TextEncoder) AddUint32

func (enc *TextEncoder) AddUint32(key string, value uint32)

func (*TextEncoder) AddUint64

func (enc *TextEncoder) AddUint64(key string, value uint64)

func (*TextEncoder) AddUint8

func (enc *TextEncoder) AddUint8(key string, value uint8)

func (*TextEncoder) AddUintptr

func (enc *TextEncoder) AddUintptr(key string, value uintptr)

func (*TextEncoder) AppendArray

func (enc *TextEncoder) AppendArray(arr zapcore.ArrayMarshaler) (err error)

Logging-specific marshalers.{}

func (*TextEncoder) AppendBool

func (enc *TextEncoder) AppendBool(value bool)

func (*TextEncoder) AppendByteString

func (enc *TextEncoder) AppendByteString(value []byte)

for UTF-8 encoded bytes

func (*TextEncoder) AppendComplex128

func (enc *TextEncoder) AppendComplex128(value complex128)

func (*TextEncoder) AppendComplex64

func (enc *TextEncoder) AppendComplex64(value complex64)

func (*TextEncoder) AppendDuration

func (enc *TextEncoder) AppendDuration(value time.Duration)

Time-related types.

func (*TextEncoder) AppendFloat32

func (enc *TextEncoder) AppendFloat32(value float32)

func (*TextEncoder) AppendFloat64

func (enc *TextEncoder) AppendFloat64(value float64)

func (*TextEncoder) AppendInt

func (enc *TextEncoder) AppendInt(value int)

func (*TextEncoder) AppendInt16

func (enc *TextEncoder) AppendInt16(value int16)

func (*TextEncoder) AppendInt32

func (enc *TextEncoder) AppendInt32(value int32)

func (*TextEncoder) AppendInt64

func (enc *TextEncoder) AppendInt64(value int64)

func (*TextEncoder) AppendInt8

func (enc *TextEncoder) AppendInt8(value int8)

func (*TextEncoder) AppendObject

func (enc *TextEncoder) AppendObject(obj zapcore.ObjectMarshaler) (err error)

func (*TextEncoder) AppendReflected

func (enc *TextEncoder) AppendReflected(value interface{}) (err error)

AppendReflected uses reflection to serialize arbitrary objects, so it's{} slow and allocation-heavy.{}

func (*TextEncoder) AppendString

func (enc *TextEncoder) AppendString(value string)

func (*TextEncoder) AppendTime

func (enc *TextEncoder) AppendTime(value time.Time)

func (*TextEncoder) AppendUint

func (enc *TextEncoder) AppendUint(value uint)

func (*TextEncoder) AppendUint16

func (enc *TextEncoder) AppendUint16(value uint16)

func (*TextEncoder) AppendUint32

func (enc *TextEncoder) AppendUint32(value uint32)

func (*TextEncoder) AppendUint64

func (enc *TextEncoder) AppendUint64(value uint64)

func (*TextEncoder) AppendUint8

func (enc *TextEncoder) AppendUint8(value uint8)

func (*TextEncoder) AppendUintptr

func (enc *TextEncoder) AppendUintptr(value uintptr)

func (*TextEncoder) Clone

func (enc *TextEncoder) Clone() zapcore.Encoder

Clone copies the encoder, ensuring that adding fields to the copy doesn't affect the original.

func (*TextEncoder) EncodeEntry

func (enc *TextEncoder) EncodeEntry(zapcore.Entry, []zapcore.Field) (buf *buffer.Buffer, err error)

EncodeEntry encodes an entry and fields, along with any accumulated context, into a byte buffer and returns ienc. Any fields that are empty, including fields on the `Entry` type, should be omitted.

func (*TextEncoder) OpenNamespace

func (enc *TextEncoder) OpenNamespace(key string)

OpenNamespace opens an isolated namespace where all subsequent fields will be added. Applications can use namespaces to prevent key collisions when injecting loggers into sub-components or third-party libraries.

Jump to

Keyboard shortcuts

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