Documentation ¶
Index ¶
- Variables
- func ErrorFilterContextCanceled(logger *zap.Logger, msg string, fields ...zap.Field)
- func FromContext(ctx context.Context) *zap.Logger
- func InitGinLogWritter() io.Writer
- func InitLogger(cfg *Config, opts ...LoggerOpt) error
- func NewContextWithLogger(ctx context.Context, logger *zap.Logger) context.Context
- func SetLogLevel(level string) error
- func ShortError(err error) zap.Field
- func WithComponent(component string) *zap.Logger
- func ZapErrorFilter(err error, filterErrors ...error) zap.Field
- type Config
- type LoggerOpt
Constants ¶
This section is empty.
Variables ¶
var ( // HideSensitive is used to replace sensitive information with `******` in log. HideSensitive = func(input string) string { output := passwordRegexp.ReplaceAllString(input, "$1******$4") output = sslRegexp.ReplaceAllString(output, "$1 \"******\"") output = sslStringRegexp.ReplaceAllString(output, "$1 \"******\"") return output } )
Functions ¶
func ErrorFilterContextCanceled ¶
ErrorFilterContextCanceled log the msg and fields but do nothing if fields have cancel error
func FromContext ¶
FromContext return the logger in context, or return global logger if logger not found in context
func InitGinLogWritter ¶
InitGinLogWritter initialize loggers for Gin.
func InitLogger ¶
InitLogger initializes logger
func NewContextWithLogger ¶
NewContextWithLogger attaches a new logger to context and return the context
func SetLogLevel ¶
SetLogLevel changes TiCDC log level dynamically.
func ShortError ¶
ShortError contructs a field which only records the error message without the verbose text (i.e. excludes the stack trace).
func WithComponent ¶
WithComponent return a logger with specified component scope
Types ¶
type Config ¶
type Config struct { // Log level. Level string `toml:"level" json:"level"` // Log filename, leave empty to disable file log. File string `toml:"file" json:"file"` // Max size for a single file, in MB. FileMaxSize int `toml:"max-size" json:"max-size"` // Max log keep days, default is never deleting. FileMaxDays int `toml:"max-days" json:"max-days"` // Maximum number of old log files to retain. FileMaxBackups int `toml:"max-backups" json:"max-backups"` // ZapInternalErrOutput specify where the internal error of zap logger should be send to. ZapInternalErrOutput string `toml:"error-output" json:"error-output"` }
Config serializes log related config in toml/json.
type LoggerOpt ¶
type LoggerOpt func(*loggerOp)
LoggerOpt is the logger option
func WithInitGRPCLogger ¶
func WithInitGRPCLogger() LoggerOpt
WithInitGRPCLogger enables grpc logger initialization when initializes global logger
func WithInitMySQLLogger ¶
func WithInitMySQLLogger() LoggerOpt
WithInitMySQLLogger enables mysql logger initialization when initializes global logger
func WithInitSaramaLogger ¶
func WithInitSaramaLogger() LoggerOpt
WithInitSaramaLogger enables sarama logger initialization when initializes global logger
func WithOutputWriteSyncer ¶
func WithOutputWriteSyncer(output zapcore.WriteSyncer) LoggerOpt
WithOutputWriteSyncer will replace the WriteSyncer of global logger with customized WriteSyncer Easy for test when using zaptest.Buffer as WriteSyncer