Documentation
¶
Index ¶
- Constants
- func New(cfg *Config) (*o_gorm.DB, error)
- type Config
- type GouefGormLogger
- func (l *GouefGormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (l *GouefGormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (l *GouefGormLogger) LogMode(level logger.LogLevel) logger.Interface
- func (l *GouefGormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *GouefGormLogger) Warn(ctx context.Context, msg string, data ...interface{})
- type LoggerConfig
Constants ¶
View Source
const ( Reset = "\033[0m" Red = "\033[31;1m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35;1m" Cyan = "\033[36m" White = "\033[37m" BlueBold = "\033[34;1m" MagentaBold = "\033[35;1m" RedBold = "\033[31;1m" YellowBold = "\033[33;1m" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Driver string `json:"driver" yaml:"driver" mapstructure:"driver"`
Host string `json:"host" yaml:"host" mapstructure:"host"`
Port int `json:"port" yaml:"port" mapstructure:"port"`
User string `json:"user" yaml:"user" mapstructure:"user"`
Password string `json:"password" yaml:"password" mapstructure:"password"`
DBName string `json:"dbname" yaml:"dbname" mapstructure:"dbname"`
SSLMode string `json:"sslmode" yaml:"sslmode" mapstructure:"sslmode"`
TimeZone string `json:"timezone" yaml:"timezone" mapstructure:"timezone"`
MaxIdleConns int `json:"max_idle_conns" yaml:"max_idle_conns" mapstructure:"max_idle_conns"`
MaxOpenConns int `json:"max_open_conns" yaml:"max_open_conns" mapstructure:"max_open_conns"`
ConnMaxLifetime time.Duration `json:"conn_max_lifetime" yaml:"conn_max_lifetime" mapstructure:"conn_max_lifetime"`
Debug bool `json:"debug" yaml:"debug" mapstructure:"debug"`
Logger LoggerConfig `json:"logger" yaml:"logger" mapstructure:"logger"`
}
type GouefGormLogger ¶ added in v1.0.2
type GouefGormLogger struct {
LogLevel logger.LogLevel
SlowThreshold time.Duration
IgnoreRecordNotFoundError bool
ParameterizedQueries bool
Colorful bool
// contains filtered or unexported fields
}
GouefGormLogger upravuje výstup tak, aby duration byl přímo v logu
func NewGouefGormLogger ¶ added in v1.0.2
func NewGouefGormLogger(config LoggerConfig) *GouefGormLogger
func (*GouefGormLogger) Error ¶ added in v1.0.2
func (l *GouefGormLogger) Error(ctx context.Context, msg string, data ...interface{})
func (*GouefGormLogger) Info ¶ added in v1.0.2
func (l *GouefGormLogger) Info(ctx context.Context, msg string, data ...interface{})
func (*GouefGormLogger) LogMode ¶ added in v1.0.2
func (l *GouefGormLogger) LogMode(level logger.LogLevel) logger.Interface
type LoggerConfig ¶ added in v1.0.1
type LoggerConfig struct {
SlowThreshold time.Duration `json:"slow_threshold" yaml:"slow_threshold" mapstructure:"slow_threshold"`
LogLevel string `json:"log_level" yaml:"log_level" mapstructure:"log_level"`
IgnoreRecordNotFoundError bool `json:"ignore_record_not_found_error" yaml:"ignore_record_not_found_error" mapstructure:"ignore_record_not_found_error"`
ParameterizedQueries bool `json:"parameterized_queries" yaml:"parameterized_queries" mapstructure:"parameterized_queries"`
Colorful bool `json:"colorful" yaml:"colorful" mapstructure:"colorful"`
}
Click to show internal directories.
Click to hide internal directories.