Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger initializes Lightning's and also the TiDB library's loggers.
func IsContextCanceledError ¶
IsContextCanceledError returns whether the error is caused by context cancellation.
func ShortError ¶
ShortError contructs a field which only records the error message without the verbose text (i.e. excludes the stack trace).
In Lightning, all errors are almost always propagated back to `main()` where the error stack is written. Including the stack in the middle thus usually just repeats known information. You should almost always use `ShortError` instead of `zap.Error`, unless the error is no longer propagated upwards.
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"` }
Config serializes log related config in toml/json.
type FilterCore ¶
FilterCore is a zapcore.Core implementation, it filters log by path-qualified package name.
func NewFilterCore ¶
func NewFilterCore(core zapcore.Core, filteredPackages ...string) *FilterCore
NewFilterCore returns a FilterCore.
Example, filter TiDB's log, `NewFilterCore(core, "github.com/pingcap/tidb/")`. Note, must set AddCaller() to the logger.
func (*FilterCore) Check ¶
func (f *FilterCore) Check(entry zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry
Check overrides wrapper core.Check and adds itself to zapcore.CheckedEntry.
type Logger ¶
Logger is a simple wrapper around *zap.Logger which provides some extra methods to simplify Lightning's log usage.
func MakeTestLogger ¶
MakeTestLogger creates a Logger instance which produces JSON logs.
type Task ¶
type Task struct { Logger // contains filtered or unexported fields }
Task is a logger for a task spanning a period of time. This structure records when the task is started, so the time elapsed for the whole task can be logged without book-keeping.