Documentation
¶
Index ¶
- Constants
- Variables
- func Adjust(logger *zap.Logger, options ...zap.Option) *zap.Logger
- func ConnectionIdField(val uint32) zap.Field
- func Debug(msg string, fields ...zap.Field)
- func Debugf(msg string, fields ...interface{})
- func Discardable() zap.Field
- func DragonboatFactory(name string) logger.ILogger
- func EnableLog() bool
- func EnableStoreDB() bool
- func Error(msg string, fields ...zap.Field)
- func ErrorField(err error) zap.Field
- func Errorf(msg string, fields ...interface{})
- func Fatal(msg string, fields ...zap.Field)
- func Fatalf(msg string, fields ...interface{})
- func GetContextFieldFunc() contextFieldFunc
- func GetCronLogger(logInfo bool) cron.Logger
- func GetErrorLogger() *zap.Logger
- func GetGlobalLogger() *zap.Logger
- func GetLogger(options ...zap.Option) *zap.Logger
- func GetLoggerWithOptions(level zapcore.LevelEnabler, encoder zapcore.Encoder, ...) *zap.Logger
- func GetPanicLogger(options ...zap.Option) *zap.Logger
- func GetPanicLoggerWithLevel(level zapcore.Level, options ...zap.Option) *zap.Logger
- func GetReportZapFunc() reportZapFunc
- func GetS3Logger() logging.Logger
- func GetSkip1Logger() *zap.Logger
- func Info(msg string, fields ...zap.Field)
- func Infof(msg string, fields ...interface{})
- func IsExpectedConnectionCloseError(err error) bool
- func LogAsyncTask(logger *zap.Logger, task string, fields ...zap.Field) func()
- func LogClose(logger *zap.Logger, components string, fields ...zap.Field) func()
- func LogConnectionCloseError(msg string, err error, fields ...zap.Field)
- func NewMOLogger(cfg *LogConfig) (*zap.Logger, error)
- func NoReportFiled() zap.Field
- func Panic(msg string, fields ...zap.Field)
- func Panicf(msg string, fields ...interface{})
- func PathField(val string) zap.Field
- func QueryField(val string) zap.Field
- func SessionIdField(val string) zap.Field
- func SetLogReporter(r *TraceReporter)
- func SetupMOLogger(conf *LogConfig)
- func StatementField(val string) zap.Field
- func StatementIdField(val string) zap.Field
- func StatusField(val string) zap.Field
- func TableField(val string) zap.Field
- func TxnIdField(val string) zap.Field
- func TxnInfoField(val string) zap.Field
- func VarsField(val string) zap.Field
- func Warn(msg string, fields ...zap.Field)
- func Warnf(msg string, fields ...interface{})
- type CronLogger
- type DragonboatAdaptLogger
- func (d DragonboatAdaptLogger) Debugf(format string, args ...interface{})
- func (d DragonboatAdaptLogger) Errorf(format string, args ...interface{})
- func (d DragonboatAdaptLogger) Infof(format string, args ...interface{})
- func (d DragonboatAdaptLogger) Panicf(format string, args ...interface{})
- func (d *DragonboatAdaptLogger) SetLevel(level logger.LogLevel)
- func (d DragonboatAdaptLogger) Warningf(format string, args ...interface{})
- type GoettyLogger
- type LogConfig
- type RateLimitConfig
- type RateLimitedLogger
- func (l *RateLimitedLogger) Error(key string, msg string, fields ...zap.Field)
- func (l *RateLimitedLogger) ErrorWithConfig(key string, msg string, config RateLimitConfig, fields ...zap.Field)
- func (l *RateLimitedLogger) Logger() *zap.Logger
- func (l *RateLimitedLogger) Reset(key string)
- func (l *RateLimitedLogger) ResetAll()
- func (l *RateLimitedLogger) Warn(key string, msg string, fields ...zap.Field)
- func (l *RateLimitedLogger) WarnWithConfig(key string, msg string, config RateLimitConfig, fields ...zap.Field)
- type S3Logger
- type TraceLogEncoder
- type TraceReporter
- type ZapSink
Constants ¶
const MOInternalFiledKeyDiscardable = "MODiscardable"
MOInternalFiledKeyDiscardable mark
const MOInternalFiledKeyNoopReport = "MOInternalFiledKeyNoopReport"
Variables ¶
var ( // DefaultRateLimitConfig is the default configuration for rate limiting. DefaultRateLimitConfig = RateLimitConfig{ Interval: 10 * time.Second, BurstCount: 3, SampleInterval: 100, } )
var SpanFieldKey atomic.Value
Functions ¶
func ConnectionIdField ¶ added in v0.6.0
func Discardable ¶ added in v1.0.0
func DragonboatFactory ¶ added in v0.6.0
DragonboatFactory implement logger.Factory for logger.SetLoggerFactory create DragonboatAdaptLogger intance
func EnableStoreDB ¶ added in v0.6.0
func EnableStoreDB() bool
func ErrorField ¶ added in v0.6.0
func GetContextFieldFunc ¶ added in v0.6.0
func GetContextFieldFunc() contextFieldFunc
func GetCronLogger ¶ added in v0.6.0
func GetErrorLogger ¶ added in v0.6.0
func GetGlobalLogger ¶
GetGlobalLogger returns the current global zap Logger.
func GetLoggerWithOptions ¶ added in v0.5.0
func GetLoggerWithOptions( level zapcore.LevelEnabler, encoder zapcore.Encoder, syncer zapcore.WriteSyncer, options ...zap.Option) *zap.Logger
GetLoggerWithOptions get default zap logger
func GetPanicLogger ¶ added in v0.5.0
GetPanicLogger returns a zap logger which will panic on Fatal(). The returned zap logger should only be used in tests.
func GetPanicLoggerWithLevel ¶ added in v0.5.0
GetPanicLoggerWithLevel returns a zap logger which will panic on Fatal(). The returned zap logger should only be used in tests.
func GetReportZapFunc ¶ added in v0.6.0
func GetReportZapFunc() reportZapFunc
func GetS3Logger ¶ added in v0.6.0
func GetSkip1Logger ¶ added in v0.6.0
func IsExpectedConnectionCloseError ¶
IsExpectedConnectionCloseError checks if the error is an expected error when closing connections. These errors occur during normal connection lifecycle and should be logged at DEBUG level. Currently only "use of closed network connection" is considered as expected.
func LogAsyncTask ¶ added in v0.6.0
LogAsyncTask used to log any async task, and will write a log if the async task exited.
func LogConnectionCloseError ¶
LogConnectionCloseError logs connection close errors at appropriate level. Expected errors (like "use of closed network connection") are logged at DEBUG level, while unexpected errors are logged at ERROR level.
func NewMOLogger ¶
NewMOLogger new a mo zap logger
func NoReportFiled ¶ added in v0.6.0
func QueryField ¶ added in v0.6.0
func SessionIdField ¶ added in v1.2.1
func SetLogReporter ¶ added in v0.6.0
func SetLogReporter(r *TraceReporter)
func SetupMOLogger ¶
func SetupMOLogger(conf *LogConfig)
SetupMOLogger sets up the global logger for MO Server.
func StatementField ¶ added in v0.6.0
func StatementIdField ¶ added in v1.2.1
func StatusField ¶ added in v0.6.0
func TableField ¶ added in v0.6.0
func TxnIdField ¶ added in v1.2.1
func TxnInfoField ¶ added in v1.2.1
Types ¶
type CronLogger ¶ added in v0.6.0
type CronLogger struct {
*zap.SugaredLogger
// contains filtered or unexported fields
}
func (*CronLogger) Error ¶ added in v0.6.0
func (l *CronLogger) Error(err error, msg string, keysAndValues ...any)
Error implement cron.Logger
func (*CronLogger) Info ¶ added in v0.6.0
func (l *CronLogger) Info(msg string, keysAndValues ...any)
Info implement cron.Logger
type DragonboatAdaptLogger ¶ added in v0.6.0
type DragonboatAdaptLogger struct {
// contains filtered or unexported fields
}
func (DragonboatAdaptLogger) Debugf ¶ added in v0.6.0
func (d DragonboatAdaptLogger) Debugf(format string, args ...interface{})
func (DragonboatAdaptLogger) Errorf ¶ added in v0.6.0
func (d DragonboatAdaptLogger) Errorf(format string, args ...interface{})
func (DragonboatAdaptLogger) Infof ¶ added in v0.6.0
func (d DragonboatAdaptLogger) Infof(format string, args ...interface{})
func (DragonboatAdaptLogger) Panicf ¶ added in v0.6.0
func (d DragonboatAdaptLogger) Panicf(format string, args ...interface{})
func (*DragonboatAdaptLogger) SetLevel ¶ added in v0.6.0
func (d *DragonboatAdaptLogger) SetLevel(level logger.LogLevel)
func (DragonboatAdaptLogger) Warningf ¶ added in v0.6.0
func (d DragonboatAdaptLogger) Warningf(format string, args ...interface{})
type GoettyLogger ¶
type GoettyLogger struct{}
func (*GoettyLogger) Debugf ¶
func (l *GoettyLogger) Debugf(msg string, fields ...interface{})
func (*GoettyLogger) Errorf ¶
func (l *GoettyLogger) Errorf(msg string, fields ...interface{})
func (*GoettyLogger) Fatalf ¶
func (l *GoettyLogger) Fatalf(msg string, fields ...interface{})
func (*GoettyLogger) Infof ¶
func (l *GoettyLogger) Infof(msg string, fields ...interface{})
type LogConfig ¶ added in v0.5.0
type LogConfig struct {
Level string `toml:"level" user_setting:"basic"`
Format string `toml:"format" user_setting:"basic"`
Filename string `toml:"filename" user_setting:"advanced"`
MaxSize int `toml:"max-size"`
MaxDays int `toml:"max-days"`
MaxBackups int `toml:"max-backups"`
// DisableStore ctrl store log into db
DisableStore bool `toml:"disable-store"`
// DisableLog ctrl log into console
DisableLog bool `toml:"disable-log"`
// StacktraceLevel
StacktraceLevel string `toml:"stacktrace-level"`
}
func GetDefaultConfig ¶ added in v1.1.0
func GetDefaultConfig() LogConfig
func (*LogConfig) GetLevel ¶ added in v1.2.1
func (cfg *LogConfig) GetLevel() zap.AtomicLevel
type RateLimitConfig ¶
type RateLimitConfig struct {
// Interval is the minimum time between log outputs for the same message.
// Default: 10 seconds
Interval time.Duration
// BurstCount is the number of logs allowed in burst before rate limiting kicks in.
// First N occurrences are always logged.
// Default: 3
BurstCount int
// SampleInterval is the count interval at which to log even when rate limited.
// e.g., 100 means log every 100th occurrence.
// Default: 100
SampleInterval int
}
RateLimitConfig configures rate limiting behavior.
type RateLimitedLogger ¶
type RateLimitedLogger struct {
// contains filtered or unexported fields
}
RateLimitedLogger wraps a zap.Logger with rate limiting to prevent log storms. It limits log output by both count and time interval.
func NewRateLimitedLogger ¶
func NewRateLimitedLogger(logger *zap.Logger) *RateLimitedLogger
NewRateLimitedLogger creates a new rate-limited logger wrapper. It automatically adds CallerSkip(2) to ensure correct caller information is displayed in logs (accounting for Error/Warn -> logWithConfig call chain).
func (*RateLimitedLogger) Error ¶
func (l *RateLimitedLogger) Error(key string, msg string, fields ...zap.Field)
Error logs at error level with rate limiting. The key parameter is used to identify unique log sources for rate limiting.
func (*RateLimitedLogger) ErrorWithConfig ¶
func (l *RateLimitedLogger) ErrorWithConfig(key string, msg string, config RateLimitConfig, fields ...zap.Field)
ErrorWithConfig logs at error level with custom rate limit configuration.
func (*RateLimitedLogger) Logger ¶
func (l *RateLimitedLogger) Logger() *zap.Logger
Logger returns the underlying zap.Logger.
func (*RateLimitedLogger) Reset ¶
func (l *RateLimitedLogger) Reset(key string)
Reset resets the rate limiting state for a specific key.
func (*RateLimitedLogger) ResetAll ¶
func (l *RateLimitedLogger) ResetAll()
ResetAll resets all rate limiting states.
func (*RateLimitedLogger) Warn ¶
func (l *RateLimitedLogger) Warn(key string, msg string, fields ...zap.Field)
Warn logs at warn level with rate limiting.
func (*RateLimitedLogger) WarnWithConfig ¶
func (l *RateLimitedLogger) WarnWithConfig(key string, msg string, config RateLimitConfig, fields ...zap.Field)
WarnWithConfig logs at warn level with custom rate limit configuration.
type TraceLogEncoder ¶ added in v0.6.0
func (*TraceLogEncoder) AddBool ¶ added in v1.0.0
func (e *TraceLogEncoder) AddBool(key string, value bool)
AddBool implements zapcore.ObjectEncoder, hook zapcore.Core's With(...) api
func (*TraceLogEncoder) AddObject ¶ added in v0.6.0
func (e *TraceLogEncoder) AddObject(key string, val zapcore.ObjectMarshaler) error
func (*TraceLogEncoder) Clone ¶ added in v0.6.0
func (e *TraceLogEncoder) Clone() zapcore.Encoder
func (*TraceLogEncoder) EncodeEntry ¶ added in v0.6.0
type TraceReporter ¶ added in v0.6.0
type TraceReporter struct {
ReportZap reportZapFunc
ContextField contextFieldFunc
}