Documentation
¶
Index ¶
- Constants
- func Close()
- func ConsoleWriter(consoleConf ...ConsoleConf) io.Writer
- func RedisWriter(redisConf ...RedisConfig) io.Writer
- func SetAttachment(kv map[string]string)
- func SetCallDepth(n int)
- func SetEnableAsync()
- func SetLevel(l Level)
- func SetOutput(w ...io.Writer)
- func TakeStacktrace(optionalSkip ...int) string
- type BasicSampler
- type Buffer
- func (b *Buffer) AppendBool(v bool)
- func (b *Buffer) AppendByte(v byte)
- func (b *Buffer) AppendFloat(f float64, bitSize int)
- func (b *Buffer) AppendInt(i int64)
- func (b *Buffer) AppendString(s string)
- func (b *Buffer) AppendUint(i uint64)
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Cap() int
- func (b *Buffer) Free()
- func (b *Buffer) Len() int
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Write(bs []byte) (int, error)
- type BurstSampler
- type ConsoleConf
- type Ctx
- type Level
- type LevelSampler
- type Log
- func (b *Log) Context() context.Context
- func (b *Log) Error(args ...interface{})
- func (b *Log) Errorf(format string, args ...interface{})
- func (b *Log) Errorln(args ...interface{})
- func (b *Log) Fatal(args ...interface{})
- func (b *Log) Fatalf(format string, args ...interface{})
- func (b *Log) Fatalln(args ...interface{})
- func (b *Log) Info(args ...interface{})
- func (b *Log) Infof(format string, args ...interface{})
- func (b *Log) Infoln(args ...interface{})
- func (b *Log) KV(key string, val string) *Log
- func (b *Log) Msg(msg ...interface{})
- func (b *Log) Msgf(msg string, v ...interface{})
- func (b *Log) Printf(format string, args ...interface{})
- func (b *Log) Stack() *Log
- func (b *Log) TraceID(traceId string) *Log
- func (b *Log) V(l int) bool
- func (b *Log) Warning(args ...interface{})
- func (b *Log) Warningf(format string, args ...interface{})
- func (b *Log) Warningln(args ...interface{})
- type Pool
- type RedisConfig
- type Sampler
- type Writer
Constants ¶
const ( DebugLevel = zerolog.DebugLevel InfoLevel = zerolog.InfoLevel WarnLevel = zerolog.WarnLevel ErrorLevel = zerolog.ErrorLevel FatalLevel = zerolog.FatalLevel Disabled = zerolog.Disabled )
const
Variables ¶
This section is empty.
Functions ¶
func ConsoleWriter ¶
func ConsoleWriter(consoleConf ...ConsoleConf) io.Writer
ConsoleWriter gens console with conf provided.
func RedisWriter ¶
func RedisWriter(redisConf ...RedisConfig) io.Writer
RedisWriter generate redis writer.
func SetEnableAsync ¶
func SetEnableAsync()
SetEnableAsync enables async log, should use Close func to wait all flushed.
func TakeStacktrace ¶
TakeStacktrace is helper func to take snap short of stack trace.
Types ¶
type BasicSampler ¶
type BasicSampler = zerolog.BasicSampler
BasicSampler is a sampler that will send every Nth events, regardless of there level.
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a thin wrapper around a byte slice. It's intended to be pooled, so the only way to construct one is via a Pool.
func (*Buffer) AppendBool ¶
AppendBool appends a bool to the underlying buffer.
func (*Buffer) AppendByte ¶
AppendByte writes a single byte to the Buffer.
func (*Buffer) AppendFloat ¶
AppendFloat appends a float to the underlying buffer. It doesn't quote NaN or +/- Inf.
func (*Buffer) AppendInt ¶
AppendInt appends an integer to the underlying buffer (assuming base 10).
func (*Buffer) AppendString ¶
AppendString writes a string to the Buffer.
func (*Buffer) AppendUint ¶
AppendUint appends an unsigned integer to the underlying buffer (assuming base 10).
func (*Buffer) Free ¶
func (b *Buffer) Free()
Free returns the Buffer to its Pool.
Callers must not retain references to the Buffer after calling Free.
func (*Buffer) Reset ¶
func (b *Buffer) Reset()
Reset resets the underlying byte slice. Subsequent writes re-use the slice's backing array.
type BurstSampler ¶
type BurstSampler = zerolog.BurstSampler
BurstSampler lets Burst events pass per Period then pass the decision to NextSampler. If Sampler is not set, all subsequent events are rejected.
type ConsoleConf ¶
ConsoleConf is conf for console writer.
func (ConsoleConf) Write ¶
func (w ConsoleConf) Write(p []byte) (n int, err error)
Write write data to writer.
func (ConsoleConf) WriteLevel ¶
func (w ConsoleConf) WriteLevel(level Level, p []byte) (n int, err error)
WriteLevel write data to writer with level info provided
type LevelSampler ¶
type LevelSampler = zerolog.LevelSampler
LevelSampler applies a different sampler for each level.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log struct.
func (*Log) Error ¶
func (b *Log) Error(args ...interface{})
Error logs to ERROR log. Arguments are handled in the manner of fmt.Print.
func (*Log) Errorln ¶
func (b *Log) Errorln(args ...interface{})
Errorln logs to ERROR log. Arguments are handled in the manner of fmt.Println.
func (*Log) Fatal ¶
func (b *Log) Fatal(args ...interface{})
Fatal logs to ERROR log. Arguments are handled in the manner of fmt.Print. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*Log) Fatalf ¶
Fatalf logs to ERROR log. Arguments are handled in the manner of fmt.Printf. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*Log) Fatalln ¶
func (b *Log) Fatalln(args ...interface{})
Fatalln logs to ERROR log. Arguments are handled in the manner of fmt.Println. gRPC ensures that all Fatal logs will exit with os.Exit(1). Implementations may also call os.Exit() with a non-zero exit code.
func (*Log) Info ¶
func (b *Log) Info(args ...interface{})
Info logs to INFO log. Arguments are handled in the manner of fmt.Print.
func (*Log) Infoln ¶
func (b *Log) Infoln(args ...interface{})
Infoln logs to INFO log. Arguments are handled in the manner of fmt.Println.
func (*Log) Warning ¶
func (b *Log) Warning(args ...interface{})
Warning logs to WARNING log. Arguments are handled in the manner of fmt.Print.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
A Pool is a type-safe wrapper around a sync.Pool.
type RedisConfig ¶
type RedisConfig struct { Level Level RedisURL string RedisPass string LogKey string // contains filtered or unexported fields }
RedisConfig is conf for redis writer.
func (RedisConfig) Write ¶
func (c RedisConfig) Write(p []byte) (n int, err error)
Write write data to writer
func (RedisConfig) WriteLevel ¶
func (c RedisConfig) WriteLevel(level Level, p []byte) (n int, err error)
WriteLevel write data to writer with level info provided
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is a io.Writer wrapper that uses a diode to make Write lock-free, non-blocking and thread safe.
func NewAsyncWriter ¶
func NewAsyncWriter(l Level, w io.Writer, manyToOneDiode *diodes.ManyToOne, poolInterval time.Duration) Writer
NewAsyncWriter 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
d := diodes.NewManyToOne(1000, diodes.AlertFunc(func(missed int) { log.Printf("Dropped %d messages", missed) })) w := diode.NewWriter(w, d, 10 * time.Millisecond) log := zerolog.New(w)
See code.cloudfoundry.org/go-diodes for more info on diode.
func (Writer) Close ¶
Close releases the diode poller and call Close on the wrapped writer if io.Closer is implemented.