Documentation
¶
Index ¶
- func BatchDebug(msg string, fields ...zap.Field)
- func BatchError(msg string, fields ...zap.Field)
- func BatchInfo(msg string, fields ...zap.Field)
- func BatchWarn(msg string, fields ...zap.Field)
- func Default() *zap.Logger
- func EnableBatchLogging(config BatchConfig)
- func FlushBatchLogs()
- func SetContextLogger(ctx context.Context, log StdLogger) context.Context
- type BatchConfig
- type BatchLogger
- func (bl *BatchLogger) Close() error
- func (bl *BatchLogger) Debug(msg string, fields ...zap.Field)
- func (bl *BatchLogger) Error(msg string, fields ...zap.Field)
- func (bl *BatchLogger) Fatal(msg string, fields ...zap.Field)
- func (bl *BatchLogger) Flush()
- func (bl *BatchLogger) Info(msg string, fields ...zap.Field)
- func (bl *BatchLogger) Stats() BatchStats
- func (bl *BatchLogger) Warn(msg string, fields ...zap.Field)
- type BatchStats
- type BatchWrapper
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchDebug ¶ added in v0.4.0
BatchDebug 全局批处理Debug日志
func BatchError ¶ added in v0.4.0
BatchError 全局批处理Error日志
func EnableBatchLogging ¶ added in v0.4.0
func EnableBatchLogging(config BatchConfig)
EnableBatchLogging 启用全局批处理日志
Types ¶
type BatchConfig ¶ added in v0.4.0
type BatchConfig struct {
FlushSize int // 批量大小,默认100
FlushInterval time.Duration // 刷新间隔,默认1秒
BufferSize int // 缓冲区大小,默认1000
}
BatchConfig 批处理配置
type BatchLogger ¶ added in v0.4.0
type BatchLogger struct {
// contains filtered or unexported fields
}
BatchLogger 批处理日志器
func NewBatchLogger ¶ added in v0.4.0
func NewBatchLogger(baseLogger *zap.Logger, config BatchConfig) *BatchLogger
NewBatchLogger 创建批处理日志器
func (*BatchLogger) Debug ¶ added in v0.4.0
func (bl *BatchLogger) Debug(msg string, fields ...zap.Field)
Debug 批处理Debug日志
func (*BatchLogger) Error ¶ added in v0.4.0
func (bl *BatchLogger) Error(msg string, fields ...zap.Field)
Error 批处理Error日志
func (*BatchLogger) Fatal ¶ added in v0.4.0
func (bl *BatchLogger) Fatal(msg string, fields ...zap.Field)
Fatal Fatal日志(立即刷新)
type BatchStats ¶ added in v0.4.0
type BatchStats struct {
TotalLogs int64 `json:"total_logs"`
BatchedLogs int64 `json:"batched_logs"`
FlushCount int64 `json:"flush_count"`
DroppedLogs int64 `json:"dropped_logs"`
AvgBatchSize float64 `json:"avg_batch_size"`
}
BatchStats 批处理统计
type BatchWrapper ¶ added in v0.4.0
type BatchWrapper struct {
*BatchLogger
// contains filtered or unexported fields
}
WithBatch 包装logger以支持批处理
func NewBatchWrapper ¶ added in v0.4.0
func NewBatchWrapper(logger *zap.Logger, config BatchConfig) *BatchWrapper
NewBatchWrapper 创建批处理包装器
type StdLogger ¶
type StdLogger interface {
// With with any map data, the value of key must be string, int ... basic value
With(m ...zap.Field) *zap.Logger
// Debug print the debug log if the len(args) is 0, the args will be ignored
Debug(msg string, fields ...zap.Field)
Info(msg string, fields ...zap.Field)
Warn(msg string, fields ...zap.Field)
Error(msg string, fields ...zap.Field)
Fatal(msg string, fields ...zap.Field)
}
StdLogger the standard logger
func GetContextLogger ¶
GetContextLogger extract logger from context
Click to show internal directories.
Click to hide internal directories.