Documentation
¶
Index ¶
- func GetGormConfig(o *Option) *gorm.Config
- func New(o *Option) *gorm.DB
- func SetAdapter(name string, driver Driver)
- type Driver
- type Logger
- func (l *Logger) Error(ctx context.Context, s string, i ...interface{})
- func (l *Logger) Info(ctx context.Context, s string, i ...interface{})
- func (l *Logger) LogMode(level logger.LogLevel) logger.Interface
- func (l *Logger) Trace(ctx context.Context, begin time.Time, ...)
- func (l *Logger) Warn(ctx context.Context, s string, i ...interface{})
- type LoggerWriterAdapter
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGormConfig ¶
func SetAdapter ¶
Types ¶
type Logger ¶
type Logger struct {
Open bool `json:"open" yaml:"open"`
Level string `json:"level" yaml:"level"`
SlowThreshold time.Duration `json:"slowThreshold" yaml:"slowThreshold"`
IgnoreRecordNotFoundError bool `json:"ignoreRecordNotFoundError" yaml:"ignoreRecordNotFoundError"`
InfoStr, WarnStr, ErrStr string
TraceStr, TraceErrStr, TraceWarnStr string
// contains filtered or unexported fields
}
type LoggerWriterAdapter ¶
type LoggerWriterAdapter interface {
Info(args ...interface{})
Warn(args ...interface{})
Error(args ...interface{})
}
type Option ¶
type Option struct {
Driver string `json:"driver" yaml:"driver"`
Host string `json:"host" yaml:"host"`
Port string `json:"port" yaml:"port"`
DbName string `json:"dbName" yaml:"dbName"`
Username string `json:"username" yaml:"username"`
Password string `json:"password" yaml:"password"`
Args string `json:"args" yaml:"args"`
Prefix string `json:"prefix" yaml:"prefix"`
LocalTime bool `json:"localTime" yaml:"localTime"`
DryRun bool `json:"dryRun" yaml:"dryRun"`
AutomaticPing bool `json:"automaticPing" yaml:"automaticPing"`
MaxIdleConns int `json:"maxIdleConns" yaml:"maxIdleConns"`
MaxOpenConns int `json:"maxOpenConns" yaml:"maxOpenConns"`
MaxLifetime time.Duration `json:"maxLifetime" yaml:"maxLifetime"`
SingularTable bool `json:"singularTable" yaml:"singularTable"`
Logger *Logger `mapstructure:"logger" json:"logger" yaml:"logger"`
// contains filtered or unexported fields
}
func (*Option) NewLogger ¶
func (o *Option) NewLogger(writer LoggerWriterAdapter)
Click to show internal directories.
Click to hide internal directories.