tidb: github.com/pingcap/tidb/util/logutil Index | Files

package logutil

import "github.com/pingcap/tidb/util/logutil"


Package Files

hex.go log.go


const (

    // DefaultLogMaxSize is the default size of log files.
    DefaultLogMaxSize = 300 // MB
    // DefaultLogFormat is the default format of the log.
    DefaultLogFormat = "text"

    // DefaultSlowThreshold is the default slow log threshold in millisecond.
    DefaultSlowThreshold = 300
    // DefaultQueryLogMaxLen is the default max length of the query in the log.
    DefaultQueryLogMaxLen = 4096
    // DefaultRecordPlanInSlowLog is the default value for whether enable log query plan in the slow log.
    DefaultRecordPlanInSlowLog = 1
    // DefaultTiDBEnableSlowLog enables TiDB to log slow queries.
    DefaultTiDBEnableSlowLog = true
const (
    // SlowLogTimeFormat is the time format for slow log.
    SlowLogTimeFormat = time.RFC3339Nano
    // OldSlowLogTimeFormat is the first version of the the time format for slow log, This is use for compatibility.
    OldSlowLogTimeFormat = "2006-01-02-15:04:05.999999999 -0700"
const TraceEventKey = "event"

TraceEventKey presents the TraceEventKey in span log.


var EmptyFileLogConfig = FileLogConfig{}

EmptyFileLogConfig is an empty FileLogConfig.

var SlowQueryLogger = log.StandardLogger()

SlowQueryLogger is used to log slow query, InitLogger will modify it according to config file.

var SlowQueryZapLogger = zaplog.L()

SlowQueryZapLogger is used to log slow query, InitZapLogger will modify it according to config file.

func BgLogger Uses

func BgLogger() *zap.Logger

BgLogger is alias of `logutil.BgLogger()`

func Event Uses

func Event(ctx context.Context, event string)

Event records event in current tracing span.

func Eventf Uses

func Eventf(ctx context.Context, format string, args ...interface{})

Eventf records event in current tracing span with format support.

func Hex Uses

func Hex(msg proto.Message) fmt.Stringer

Hex defines a fmt.Stringer for proto.Message. We can't define the String() method on proto.Message, but we can wrap it.

func InitLogger Uses

func InitLogger(cfg *LogConfig) error

InitLogger initializes PD's logger.

func InitZapLogger Uses

func InitZapLogger(cfg *LogConfig) error

InitZapLogger initializes a zap logger with cfg.

func Logger Uses

func Logger(ctx context.Context) *zap.Logger

Logger gets a contextual logger from current context. contextual logger will output common fields from context.

func SetLevel Uses

func SetLevel(level string) error

SetLevel sets the zap logger's level.

func SetTag Uses

func SetTag(ctx context.Context, key string, value interface{})

SetTag sets tag kv-pair in current tracing span

func WithConnID Uses

func WithConnID(ctx context.Context, connID uint32) context.Context

WithConnID attaches connId to context.

func WithKeyValue Uses

func WithKeyValue(ctx context.Context, key, value string) context.Context

WithKeyValue attaches key/value to context.

func WithTraceLogger Uses

func WithTraceLogger(ctx context.Context, connID uint32) context.Context

WithTraceLogger attaches trace identifier to context

type FileLogConfig Uses

type FileLogConfig struct {

FileLogConfig serializes file log related config in toml/json.

func NewFileLogConfig Uses

func NewFileLogConfig(maxSize uint) FileLogConfig

NewFileLogConfig creates a FileLogConfig.

type LogConfig Uses

type LogConfig struct {

    // SlowQueryFile filename, default to File log config on empty.
    SlowQueryFile string

LogConfig serializes log related config in toml/json.

func NewLogConfig Uses

func NewLogConfig(level, format, slowQueryFile string, fileCfg FileLogConfig, disableTimestamp bool, opts ...func(*zaplog.Config)) *LogConfig

NewLogConfig creates a LogConfig.

Package logutil imports 22 packages (graph) and is imported by 355 packages. Updated 2020-10-22. Refresh now. Tools for package owners.