Documentation ¶
Overview ¶
Package randring provides a ring buckets for multi-producer & one-consumer which will drop messages if buckets full and won't guarantee order. randring only cares about memory corruption.
Index ¶
- Constants
- type AtomicLevel
- func (lvl AtomicLevel) Enabled(l zapcore.Level) bool
- func (lvl AtomicLevel) Level() zapcore.Level
- func (lvl AtomicLevel) MarshalText() (text []byte, err error)
- func (lvl AtomicLevel) SetLevel(l zapcore.Level)
- func (lvl AtomicLevel) String() string
- func (lvl *AtomicLevel) UnmarshalText(text []byte) error
- type Field
- func Array(key string, val zapcore.ArrayMarshaler) Field
- func Binary(key string, val []byte) Field
- func Bool(key string, val bool) Field
- func Bools(key string, bs []bool) Field
- func ByteString(key string, val []byte) Field
- func ByteStrings(key string, bss [][]byte) Field
- func Complex128(key string, val complex128) Field
- func Complex128s(key string, nums []complex128) Field
- func Complex64(key string, val complex64) Field
- func Complex64s(key string, nums []complex64) Field
- func Duration(key string, val time.Duration) Field
- func Durations(key string, ds []time.Duration) Field
- func Error(err error) Field
- func Errors(key string, errs []error) Field
- func Float32(key string, val float32) Field
- func Float32s(key string, nums []float32) Field
- func Float64(key string, val float64) Field
- func Float64s(key string, nums []float64) Field
- func Int(key string, val int) Field
- func Int16(key string, val int16) Field
- func Int16s(key string, nums []int16) Field
- func Int32(key string, val int32) Field
- func Int32s(key string, nums []int32) Field
- func Int64(key string, val int64) Field
- func Int64s(key string, nums []int64) Field
- func Int8(key string, val int8) Field
- func Int8s(key string, nums []int8) Field
- func Ints(key string, nums []int) Field
- func NamedError(key string, err error) Field
- func Namespace(key string) Field
- func Object(key string, val zapcore.ObjectMarshaler) Field
- func Reflect(key string, val interface{}) Field
- func Skip() Field
- func String(key string, val string) Field
- func Stringer(key string, val fmt.Stringer) Field
- func Strings(key string, ss []string) Field
- func Time(key string, val int64) Field
- func Times(key string, ts []time.Time) Field
- func Uint(key string, val uint) Field
- func Uint16(key string, val uint16) Field
- func Uint16s(key string, nums []uint16) Field
- func Uint32(key string, val uint32) Field
- func Uint32s(key string, nums []uint32) Field
- func Uint64(key string, val uint64) Field
- func Uint64s(key string, nums []uint64) Field
- func Uint8(key string, val uint8) Field
- func Uint8s(key string, nums []uint8) Field
- func Uintptr(key string, val uintptr) Field
- func Uintptrs(key string, us []uintptr) Field
- func Uints(key string, nums []uint) Field
- type LevelEnablerFunc
- type Logger
- func (log *Logger) Close()
- func (log *Logger) Core() zapcore.Core
- func (log *Logger) Debug(reqid uint64, msg string)
- func (log *Logger) Debugf(reqid uint64, format string, args ...interface{})
- func (log *Logger) Error(reqid uint64, msg string)
- func (log *Logger) Errorf(reqid uint64, format string, args ...interface{})
- func (log *Logger) Fatal(reqid uint64, msg string)
- func (log *Logger) Fatalf(reqid uint64, format string, args ...interface{})
- func (log *Logger) Info(reqid uint64, msg string)
- func (log *Logger) Infof(reqid uint64, format string, args ...interface{})
- func (log *Logger) Panic(reqid uint64, msg string)
- func (log *Logger) Panicf(reqid uint64, format string, args ...interface{})
- func (log *Logger) Sync() error
- func (log *Logger) Warn(reqid uint64, msg string)
- func (log *Logger) Warnf(reqid uint64, format string, args ...interface{})
- type Ring
Constants ¶
const ( // DebugLevel logs are typically voluminous, and are usually disabled in // production. DebugLevel = zapcore.DebugLevel // InfoLevel is the default logging priority. InfoLevel = zapcore.InfoLevel // WarnLevel logs are more important than Info, but don't need individual // human review. WarnLevel = zapcore.WarnLevel // ErrorLevel logs are high-priority. If an application is running smoothly, // it shouldn't generate any error-level logs. ErrorLevel = zapcore.ErrorLevel // PanicLevel logs a message, then panics. PanicLevel = zapcore.PanicLevel // FatalLevel logs a message, then calls os.Exit(1). FatalLevel = zapcore.FatalLevel )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomicLevel ¶
type AtomicLevel struct {
// contains filtered or unexported fields
}
An AtomicLevel is an atomically changeable, dynamic logging level. It lets you safely change the log level of a tree of loggers (the root logger and any children created by adding context) at runtime.
The AtomicLevel itself is an http.Handler that serves a JSON endpoint to alter its level.
AtomicLevels must be created with the NewAtomicLevel constructor to allocate their internal atomic pointer.
func NewAtomicLevel ¶
func NewAtomicLevel() AtomicLevel
NewAtomicLevel creates an AtomicLevel with InfoLevel and above logging enabled.
func NewAtomicLevelAt ¶
func NewAtomicLevelAt(l zapcore.Level) AtomicLevel
NewAtomicLevelAt is a convenience function that creates an AtomicLevel and then calls SetLevel with the given level.
func (AtomicLevel) Enabled ¶
func (lvl AtomicLevel) Enabled(l zapcore.Level) bool
Enabled implements the zapcore.LevelEnabler interface, which allows the AtomicLevel to be used in place of traditional static levels.
func (AtomicLevel) Level ¶
func (lvl AtomicLevel) Level() zapcore.Level
Level returns the minimum enabled log level.
func (AtomicLevel) MarshalText ¶
func (lvl AtomicLevel) MarshalText() (text []byte, err error)
MarshalText marshals the AtomicLevel to a byte slice. It uses the same text representation as the static zapcore.Levels ("debug", "info", "warn", "error", "dpanic", "panic", and "fatal").
func (AtomicLevel) SetLevel ¶
func (lvl AtomicLevel) SetLevel(l zapcore.Level)
SetLevel alters the logging level.
func (AtomicLevel) String ¶
func (lvl AtomicLevel) String() string
String returns the string representation of the underlying Level.
func (*AtomicLevel) UnmarshalText ¶
func (lvl *AtomicLevel) UnmarshalText(text []byte) error
UnmarshalText unmarshals the text to an AtomicLevel. It uses the same text representations as the static zapcore.Levels ("debug", "info", "warn", "error", "dpanic", "panic", and "fatal").
type Field ¶
Field is an alias for Field. Aliasing this type dramatically improves the navigability of this package's API documentation.
func Array ¶
func Array(key string, val zapcore.ArrayMarshaler) Field
Array constructs a field with the given key and ArrayMarshaler. It provides a flexible, but still type-safe and efficient, way to add array-like types to the logging context. The struct's MarshalLogArray method is called lazily.
func Binary ¶
Binary constructs a field that carries an opaque binary blob.
Binary data is serialized in an encoding-appropriate format. For example, zap's JSON encoder base64-encodes binary blobs. To log UTF-8 encoded text, use ByteString.
func ByteString ¶
ByteString constructs a field that carries UTF-8 encoded text as a []byte. To log opaque binary blobs (which aren't necessarily valid UTF-8), use Binary.
func ByteStrings ¶
ByteStrings constructs a field that carries a slice of []byte, each of which must be UTF-8 encoded text.
func Complex128 ¶
func Complex128(key string, val complex128) Field
Complex128 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex128 to interface{}).
func Complex128s ¶
func Complex128s(key string, nums []complex128) Field
Complex128s constructs a field that carries a slice of complex numbers.
func Complex64 ¶
Complex64 constructs a field that carries a complex number. Unlike most numeric fields, this costs an allocation (to convert the complex64 to interface{}).
func Complex64s ¶
Complex64s constructs a field that carries a slice of complex numbers.
func Duration ¶
Duration constructs a field with the given key and value. The encoder controls how the duration is serialized.
func Float32 ¶
Float32 constructs a field that carries a float32. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func Float64 ¶
Float64 constructs a field that carries a float64. The way the floating-point value is represented is encoder-dependent, so marshaling is necessarily lazy.
func NamedError ¶
NamedError constructs a field that lazily stores err.Error() under the provided key. Errors which also implement fmt.Formatter (like those produced by github.com/pkg/errors) will also have their verbose representation stored under key+"Verbose". If passed a nil error, the field is a no-op.
For the common case in which the key is simply "error", the Error function is shorter and less repetitive.
func Namespace ¶
Namespace creates a named, isolated scope within the logger's context. All subsequent fields will be added to the new namespace.
This helps prevent key collisions when injecting loggers into sub-components or third-party libraries.
func Object ¶
func Object(key string, val zapcore.ObjectMarshaler) Field
Object constructs a field with the given key and ObjectMarshaler. It provides a flexible, but still type-safe and efficient, way to add map- or struct-like user-defined types to the logging context. The struct's MarshalLogObject method is called lazily.
func Reflect ¶
Reflect constructs a field with the given key and an arbitrary object. It uses an encoding-appropriate, reflection-based function to lazily serialize nearly any object into the logging context, but it's relatively slow and allocation-heavy. Outside tests, Any is always a better choice.
If encoding fails (e.g., trying to serialize a map[int]string to JSON), Reflect includes the error message in the final log output.
func Skip ¶
func Skip() Field
Skip constructs a no-op field, which is often useful when handling invalid inputs in other Field constructors.
func Stringer ¶
Stringer constructs a field with the given key and the output of the value's String method. The Stringer's String method is called lazily.
func Time ¶
Time constructs a Field with the given key and value. The encoder controls how the time is serialized.
type LevelEnablerFunc ¶
LevelEnablerFunc is a convenient way to implement zapcore.LevelEnabler with an anonymous function.
It's particularly useful when splitting log output between different outputs (e.g., standard error and standard out). For sample code, see the package-level AdvancedConfiguration example.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
For nanozap, the random order only happens when there is a flood, and random order logs won't cause serious issues.
func New ¶
New constructs a new Logger from the provided zapcore.Core. If the passed zapcore.Core is nil, it panic.
func (*Logger) Close ¶
func (log *Logger) Close()
Close close Logger background loop. Without guarantee anything except exiting loop.
func (*Logger) Fatal ¶
Fatal logs a message at FatalLevel.
The logger then calls os.Exit(1), even if logging at FatalLevel is disabled.
func (*Logger) Panic ¶
Panic logs a message at PanicLevel. T
The logger then panics, even if logging at PanicLevel is disabled.
func (*Logger) Sync ¶
Sync calls the underlying Core's Sync method, flushing any buffered log entries. Applications should take care to call Sync before exiting.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package buffer provides a thin wrapper around a byte slice.
|
Package buffer provides a thin wrapper around a byte slice. |
internal
|
|
bufferpool
Package bufferpool houses zap's shared internal buffer pool.
|
Package bufferpool houses zap's shared internal buffer pool. |
zaproll provides a rolling logger for nanozap.
|
zaproll provides a rolling logger for nanozap. |