gdb

package
v0.0.0-...-1369677 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileWithLineNum

func FileWithLineNum() string

FileWithLineNum 获取调用堆栈信息

func MustNewDB

func MustNewDB(c *Config) *gorm.DB

MustNewDB 新建gorm.DB对象

func NewDB

func NewDB(c *Config) (*gorm.DB, error)

NewDB 新建gorm.DB对象

Types

type Config

type Config struct {
	User               string `toml:"user" json:"user"`                                                                        // 用户
	Password           string `toml:"password" json:"password"`                                                                // 密码
	Host               string `toml:"host" json:"host"`                                                                        // 地址
	Port               int    `toml:"port" json:"port"`                                                                        // 端口
	Database           string `toml:"database" json:"database"`                                                                // 数据库
	MaxIdleConns       int    `toml:"max_idle_conns" mapstructure:"max_idle_conns" json:"max_idle_conns"`                      // 最大空闲连接数
	MaxOpenConns       int    `toml:"max_open_conns" mapstructure:"max_open_conns" json:"max_open_conns"`                      // 最大打开连接数
	MaxConnMaxLifetime int64  `toml:"max_conn_max_lifetime" mapstructure:"max_conn_max_lifetime" json:"max_conn_max_lifetime"` // 连接复用时间
	LogLevel           string `toml:"log_level" mapstructure:"log_level" json:"log_level"`                                     // 日志级别,枚举(info、warn、error和silent)
}

Config 数据库相关配置

func (*Config) CreateDatabase

func (c *Config) CreateDatabase() error

CreateDatabase 创建数据库

func (*Config) GetDataSource

func (c *Config) GetDataSource() string

GetDataSource 获取GORM Data Source信息

func (*Config) GetGormConfig

func (c *Config) GetGormConfig() *gorm.Config

GetGormConfig 获取GORM相关配置

func (*Config) GetMySQLConfig

func (c *Config) GetMySQLConfig() mysql.Config

GetMySQLConfig 获取GORM MySQL相关配置

type Logger

type Logger struct {
	LogLevel      logger.LogLevel
	SlowThreshold time.Duration
}

Logger 日志记录器

func NewLogger

func NewLogger(logLevel logger.LogLevel, slowThreshold time.Duration) *Logger

NewLogger 新建日志记录器

func (*Logger) Error

func (l *Logger) Error(ctx context.Context, msg string, data ...interface{})

Error Error日志记录

func (*Logger) Info

func (l *Logger) Info(ctx context.Context, msg string, data ...interface{})

Info Info日志记录

func (*Logger) LogMode

func (l *Logger) LogMode(level logger.LogLevel) logger.Interface

LogMode 设置日志记录模式

func (*Logger) Trace

func (l *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

Trace Trace日志记录

func (*Logger) Warn

func (l *Logger) Warn(ctx context.Context, msg string, data ...interface{})

Warn Warn日志记录

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL