add log config and gorm config

This commit is contained in:
landaiqing
2024-08-03 22:09:19 +08:00
parent 908a9d10f2
commit 3dac34d307
10 changed files with 232 additions and 31 deletions

View File

@@ -2,9 +2,9 @@ package config
// Logger 配置
type Logger struct {
Level string `yaml:"level"` // 日志级别
Prefix string `yaml:"prefix"` // 日志前缀
Director string `yaml:"director"` // 日志文件存放目录
ShowLine string `yaml:"showLine"` // 是否显示文件行号
LogInConsole string `yaml:"logInConsole"` // 是否在控制台打印日志
Level string `yaml:"level"` // 日志级别
Prefix string `yaml:"prefix"` // 日志前缀
Director string `yaml:"director"` // 日志文件存放目录
ShowLine bool `yaml:"show-line"` // 是否显示文件行号
LogInConsole string `yaml:"log-in-console"` // 是否在控制台打印日志
}

View File

@@ -1,11 +1,20 @@
package config
import "strconv"
// MySQL 配置
type MySQL struct {
Host string `yaml:"host"` //主机地址
Port string `yaml:"port"` //端口号
DB string `yaml:"db"` //数据库名
User string `yaml:"user"` //用户名
Password string `yaml:"password"` //密码
LogLevel string `yaml:"log-level"` // 日志级别 debug: 输出全部SQL语句; release: 只输出错误信息
Host string `yaml:"host"` //主机地址
Port int `yaml:"port"` //端口号
DB string `yaml:"db"` //数据库名
User string `yaml:"user"` //用户名
Password string `yaml:"password"` //密码
LogLevel string `yaml:"log-level"` //日志级别 debug: 输出全部SQL语句; release: 只输出错误信息
Config string `yaml:"config"` //高级配置
MaxIdleConnes int `yaml:"max-idle-connes"` //最大空闲连接数
MaxOpenConnes int `yaml:"max-open-connes"` //最大连接数
}
func (m *MySQL) Dsn() string {
return m.User + ":" + m.Password + "@tcp(" + m.Host + ":" + strconv.Itoa(m.Port) + ")/" + m.DB + "?" + m.Config
}