Documentation ¶
Index ¶
- Constants
- Variables
- func Default() types.Logger
- func LevelFromZap(level zapcore.Level) types.Level
- func LevelToZap(level types.Level) zapcore.Level
- func New(logger *zap.Logger, opts ...types.Option) types.Logger
- type CompactLogger
- func (l *CompactLogger) Emitter() types.Emitter
- func (l *CompactLogger) Flush()
- func (l *CompactLogger) Level() types.Level
- func (l *CompactLogger) Log(level types.Level, values ...any)
- func (l *CompactLogger) LogFields(level types.Level, message string, fields field.AbstractFields)
- func (l *CompactLogger) Logf(level types.Level, format string, args ...any)
- func (l *CompactLogger) WithContextFields(allFields *field.FieldsChain, newFieldsCount int) belt.Tool
- func (l *CompactLogger) WithEntryProperties(props ...types.EntryProperty) adapter.CompactLogger
- func (l *CompactLogger) WithField(key field.Key, value field.Value, props ...field.Property) adapter.CompactLogger
- func (l *CompactLogger) WithFields(fields field.AbstractFields) adapter.CompactLogger
- func (l *CompactLogger) WithHooks(hooks ...types.Hook) adapter.CompactLogger
- func (l *CompactLogger) WithLevel(newLevel types.Level) adapter.CompactLogger
- func (l *CompactLogger) WithMessagePrefix(prefix string) adapter.CompactLogger
- func (l *CompactLogger) WithPreHooks(preHooks ...types.PreHook) adapter.CompactLogger
- func (l *CompactLogger) WithTraceIDs(allTraceIDs belt.TraceIDs, newTraceIDsCount int) belt.Tool
- type Emitter
- type EntryProperty
Constants ¶
const ( // EntryPropertyIgnoreFields means the provided fields in types.Entry.Fields should be // ignored by Emitter.LogEntry. // // This property is used when the fields are already set in the zap.Logger and therefore // it is just an optimization (to avoid useless calculations and memory allocations). EntryPropertyIgnoreFields )
Variables ¶
var DefaultZapLogger = func() *zap.Logger { cfg := zap.NewProductionConfig() cfg.Level = zap.NewAtomicLevelAt(LevelToZap(logger.LevelTrace)) zapLogger, err := cfg.Build() if err != nil { panic(err) } return zapLogger }
DefaultZapLogger is the (overridable) function which returns a zap logger with the default configuration.
Do not override this anywhere but in the `main` package.
var (
// FieldNameTraceIDs is the field name used to store belt.TraceIDs.
FieldNameTraceIDs = "trace_id"
)
Functions ¶
func LevelFromZap ¶
LevelFromZap converts zap's logging level to logger.Level.
func LevelToZap ¶
LevelToZap converts logger.Level to zap's logging level.
Types ¶
type CompactLogger ¶
type CompactLogger struct {
// contains filtered or unexported fields
}
CompactLogger is an implementation of types.CompactLogger based on a zap logger.
func (*CompactLogger) Emitter ¶
func (l *CompactLogger) Emitter() types.Emitter
Emitter implements types.CompactLogger.
func (*CompactLogger) Level ¶
func (l *CompactLogger) Level() types.Level
Level implements types.CompactLogger.
func (*CompactLogger) Log ¶
func (l *CompactLogger) Log(level types.Level, values ...any)
Log implements types.CompactLogger.
func (*CompactLogger) LogFields ¶
func (l *CompactLogger) LogFields(level types.Level, message string, fields field.AbstractFields)
LogFields implements types.CompactLogger.
func (*CompactLogger) Logf ¶
func (l *CompactLogger) Logf(level types.Level, format string, args ...any)
Logf implements types.CompactLogger.
func (*CompactLogger) WithContextFields ¶
func (l *CompactLogger) WithContextFields(allFields *field.FieldsChain, newFieldsCount int) belt.Tool
WithContextFields implements types.CompactLogger and belt.Tool.
func (*CompactLogger) WithEntryProperties ¶
func (l *CompactLogger) WithEntryProperties(props ...types.EntryProperty) adapter.CompactLogger
WithEntryProperties implements types.CompactLogger.
func (*CompactLogger) WithField ¶
func (l *CompactLogger) WithField( key field.Key, value field.Value, props ...field.Property, ) adapter.CompactLogger
WithField implements types.CompactLogger.
func (*CompactLogger) WithFields ¶
func (l *CompactLogger) WithFields(fields field.AbstractFields) adapter.CompactLogger
WithFields implements types.CompactLogger.
func (*CompactLogger) WithHooks ¶
func (l *CompactLogger) WithHooks(hooks ...types.Hook) adapter.CompactLogger
WithHooks implements types.CompactLogger.
func (*CompactLogger) WithLevel ¶
func (l *CompactLogger) WithLevel(newLevel types.Level) adapter.CompactLogger
WithLevel implements types.CompactLogger.
func (*CompactLogger) WithMessagePrefix ¶
func (l *CompactLogger) WithMessagePrefix(prefix string) adapter.CompactLogger
WithMessagePrefix implements types.CompactLogger.
func (*CompactLogger) WithPreHooks ¶
func (l *CompactLogger) WithPreHooks(preHooks ...types.PreHook) adapter.CompactLogger
WithPreHooks implements types.CompactLogger.
func (*CompactLogger) WithTraceIDs ¶
func (l *CompactLogger) WithTraceIDs(allTraceIDs belt.TraceIDs, newTraceIDsCount int) belt.Tool
WithTraceIDs implements types.CompactLogger and belt.Tool.
type Emitter ¶
Emitter is the implementation of types.Emitter based on a zap (non-sugared) logger.
func NewEmitter ¶
NewEmitter returns a new instance of Emitter
func (Emitter) CheckLevel ¶
CheckLevel returns true if the given types.Level is enabled in this logger.
func (Emitter) CheckZapLevel ¶
CheckZapLevel returns true if the given zap's logging level is enabled in this logger.
type EntryProperty ¶
type EntryProperty uint
EntryProperty is a type of values which could be used in field types.Entry.Properties.