logs

package
v0.0.0-...-d691e2b Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Provides a thread-safe, lock-free, non-blocking io.Writer wrapper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(v *Logger) bool

Check if need to print log

func ConfigDefaultLogger

func ConfigDefaultLogger(lc *LoggerConfig)

func Debug

func Debug(msg string, fields ...zap.Field)

func Debugf

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

func Error

func Error(msg string, fields ...zap.Field)

func Errorf

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

func Exitf

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

func Fatal

func Fatal(msg string, fields ...zap.Field)

func Fatalf

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

func FlushLogs

func FlushLogs()

func Info

func Info(msg string, fields ...zap.Field)

func Infof

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

Infof is a repalcement of glog.Infof()

func InitLogs

func InitLogs()

InitLogs need to be called explicit in the main application

func InitSummaryLogs

func InitSummaryLogs()

InitSummaryLogs init a logger to record summary

func TimeTrack

func TimeTrack(start time.Time, name string)

TimeTrack

func Warn

func Warn(msg string, fields ...zap.Field)

func Warnf

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

Types

type Alerter

type Alerter func(missed int)

type DiodeWriter

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

DiodeWriter is a io.Writer wrapper that uses a diode to make Write lock-free, non-blocking and thread safe.

func NewDiodeWriter

func NewDiodeWriter(w io.Writer, size int, poolInterval time.Duration, f Alerter) DiodeWriter

NewDiodeWriter creates a writer wrapping w with a many-to-one diode in order to never block log producers and drop events if the writer can't keep up with the flow of data.

Use a diode.Writer when

wr := diode.NewDiodeWriter(w, 1000, 10 * time.Millisecond, func(missed int) {
    log.Printf("Dropped %d messages", missed)
})
log := zerolog.New(wr)

See code.cloudfoundry.org/go-diodes for more info on diode.

func (DiodeWriter) Close

func (dw DiodeWriter) Close() error

Close releases the diode poller and call Close on the wrapped writer if io.Closer is implemented.

func (DiodeWriter) Write

func (dw DiodeWriter) Write(p []byte) (n int, err error)

type Level

type Level int32

Level specifies a level of verbosity for V logs. *Level implements flag.Value; the -v flag is of type Level and should be modified only through the flag.Value interface.

func (*Level) Get

func (l *Level) Get() interface{}

Get is part of the flag.Value interface.

func (*Level) Set

func (l *Level) Set(value string) error

Set is part of the flag.Value interface.

func (*Level) String

func (l *Level) String() string

String is part of the flag.Value interface.

type Logger

type Logger zap.Logger

Logger xxx

func NewLogger

func NewLogger() *Logger

NewLogger creates a new log.Logger

func NewSummaryLogger

func NewSummaryLogger() *Logger

NewSummaryLogger creates a new log.Logger

func V

func V(level Level) *Logger

V is a replacement of glog.V()

func (*Logger) AddCallerSkip

func (l *Logger) AddCallerSkip(n int) *Logger

func (*Logger) Debug

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

Debug is equivalent to the global Debug function, guarded by the value of v. See the documentation of V for usage.

func (*Logger) Debugf

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

Debugf is equivalent to the global Debugf function, guarded by the value of v. See the documentation of V for usage.

func (*Logger) Error

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

func (*Logger) Errorf

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

func (*Logger) Fatalf

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

func (*Logger) Info

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

Info is equivalent to the global Info function, guarded by the value of v. See the documentation of V for usage.

func (*Logger) Infof

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

Infof is equivalent to the global Infof function, guarded by the value of v. See the documentation of V for usage.

func (*Logger) TimeTrack

func (l *Logger) TimeTrack(start time.Time, thumbnail string, fields ...zap.Field)

func (*Logger) V

func (l *Logger) V(level Level) *Logger

V is a replacement of glog.V()

func (*Logger) Warn

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

Warn is equivalent to the global Warn function, guarded by the value of v. See the documentation of V for usage.

func (*Logger) Warnf

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

func (*Logger) With

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

func (*Logger) WithField

func (l *Logger) WithField(k, v string) *Logger

func (*Logger) WithStringField

func (l *Logger) WithStringField(k, v string) *Logger

type LoggerConfig

type LoggerConfig struct {
	LogDir    string
	Verbosity Level
}

type Rotate

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

Rotate implement a lock-free logrotater

func NewRotate

func NewRotate(dir, name, tag string, opts ...RotateOpt) *Rotate

NewRotate create a Rotate

func (*Rotate) Write

func (r *Rotate) Write(p []byte) (int, error)

Write implement interface of io.Writer

type RotateOpt

type RotateOpt func(*Rotate)

RotateOpt is options

func SetRotateSize

func SetRotateSize(size int64) RotateOpt

SetRotateSize set file rotate max size

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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