func ShortError(err error) zap.Field {
	if err == nil {
		return zap.Skip()
	}
	return zap.String("error", err.Error())
}
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.
package log
import (
	"context"
	"time"
	"github.com/pingcap/errors"
	pclog "github.com/pingcap/log"
	"github.com/pingcap/tidb/util/logutil"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)
const (
	defaultLogLevel   = "info"
	defaultLogMaxDays = 7
	defaultLogMaxSize = 512  
)
type Config struct {
	Level string `toml:"level" json:"level"`
	File string `toml:"file" json:"file"`
	FileMaxSize int `toml:"max-size" json:"max-size"`
	FileMaxDays int `toml:"max-days" json:"max-days"`
	FileMaxBackups int `toml:"max-backups" json:"max-backups"`
}
func (cfg *Config) Adjust() {
	if len(cfg.Level) == 0 {
		cfg.Level = defaultLogLevel
	}
	if cfg.Level == "warning" {
		cfg.Level = "warn"
	}
	if cfg.FileMaxSize == 0 {
		cfg.FileMaxSize = defaultLogMaxSize
	}
	if cfg.FileMaxDays == 0 {
		cfg.FileMaxDays = defaultLogMaxDays
	}
}
type Logger struct {
	*zap.Logger
}
var (
	appLogger = Logger{zap.NewNop()}
	appLevel  = zap.NewAtomicLevel()
)
func InitLogger(cfg *Config, tidbLoglevel string) error {
	logutil.InitLogger(&logutil.LogConfig{Config: pclog.Config{Level: tidbLoglevel}})
	logCfg := &pclog.Config{
		Level: cfg.Level,
	}
	if len(cfg.File) > 0 {
		logCfg.File = pclog.FileLogConfig{
			Filename:   cfg.File,
			MaxSize:    cfg.FileMaxSize,
			MaxDays:    cfg.FileMaxDays,
			MaxBackups: cfg.FileMaxBackups,
		}
	}
	logger, props, err := pclog.InitLogger(logCfg)
	if err != nil {
		return err
	}
	appLogger = Logger{logger.WithOptions(zap.AddStacktrace(zap.DPanicLevel))}
	appLevel = props.Level
	return nil
}
func L() Logger {
	return appLogger
}
func SetAppLogger(l *zap.Logger) {
	appLogger = Logger{l.WithOptions(zap.AddStacktrace(zap.DPanicLevel))}
}
func Level() zapcore.Level {
	return appLevel.Level()
}
func SetLevel(level zapcore.Level) zapcore.Level {
	oldLevel := appLevel.Level()
	appLevel.SetLevel(level)
	return oldLevel
}