Documentation ¶
Index ¶
- func Build(name string) *gorm.DB
- func NewLogger(level gormlogger.LogLevel, slowThreshold time.Duration) gormlogger.Interface
- func OpenMysql(dbConfig *Config) (*gorm.DB, error)
- func UnmarshalText(text string) gormlogger.LogLevel
- type Config
- type Logger
- func (l Logger) Error(_ context.Context, str string, args ...interface{})
- func (l Logger) Info(_ context.Context, str string, args ...interface{})
- func (l *Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
- func (l Logger) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l Logger) Warn(_ context.Context, str string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶
func NewLogger(level gormlogger.LogLevel, slowThreshold time.Duration) gormlogger.Interface
func UnmarshalText ¶
func UnmarshalText(text string) gormlogger.LogLevel
Types ¶
type Config ¶
type Config struct { Name string // DSN地址: mysql://root:secret@tcp(127.0.0.1:3307)/mysql?timeout=20s&readTimeout=20s DSN string DSNReplicas []string // Debug开关 LogLevel string // 最大空闲连接数 MaxIdleConns int // 最大活动连接数 MaxOpenConns int // 连接的最大存活时间 ConnMaxLifetime time.Duration // 慢日志阈值 SlowThreshold time.Duration // 生成 SQL 但不执行 DryRun bool // 跳过默认事务 SkipDefaultTransaction bool }
config options
type Logger ¶
type Logger struct { LogLevel gormlogger.LogLevel SlowThreshold time.Duration }
func (*Logger) LogMode ¶
func (l *Logger) LogMode(level gormlogger.LogLevel) gormlogger.Interface
Click to show internal directories.
Click to hide internal directories.