Skip to content

Commit

Permalink
Update logger
Browse files Browse the repository at this point in the history
  • Loading branch information
shenghui0779 committed Dec 8, 2023
1 parent 5aec49f commit 1d90132
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
4 changes: 0 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type DBConfig struct {
// [Postgres] host=localhost port=5432 user=root password=secret dbname=test connect_timeout=10 sslmode=disable
// [- SQLite] file::memory:?cache=shared
DSN string `json:"dsn"`

// Options 配置选项
Options *DBOptions `json:"options"`
}
Expand All @@ -40,13 +39,10 @@ type DBConfig struct {
type DBOptions struct {
// MaxOpenConns 设置最大可打开的连接数
MaxOpenConns int `json:"max_open_conns"`

// MaxIdleConns 连接池最大闲置连接数
MaxIdleConns int `json:"max_idle_conns"`

// ConnMaxLifetime 连接的最大生命时长
ConnMaxLifetime time.Duration `json:"conn_max_lifetime"`

// ConnMaxIdleTime 连接最大闲置时间
ConnMaxIdleTime time.Duration `json:"conn_max_idle_time"`
}
Expand Down
8 changes: 1 addition & 7 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var (
type LoggerConfig struct {
// Filename 日志名称
Filename string `json:"filename"`

// Options 日志选项
Options *LoggerOptions `json:"options"`
}
Expand All @@ -27,19 +26,14 @@ type LoggerConfig struct {
type LoggerOptions struct {
// MaxSize 当前文件多大时轮替;默认:100MB
MaxSize int `json:"max_size"`

// MaxAge 轮替的旧文件最大保留时长;默认:不限
MaxAge int `json:"max_age"`

// MaxBackups 轮替的旧文件最大保留数量;默认:不限
MaxBackups int `json:"max_backups"`

// Compress 轮替的旧文件是否压缩;默认:不压缩
Compress bool `json:"compress"`

// Stderr 是否输出到控制台
Stderr bool `json:"stderr"`

// ZapOpts Zap日志选项
ZapOpts []zap.Option `json:"zap_opts"`
}
Expand All @@ -59,7 +53,7 @@ func debugLogger(options ...zap.Option) *zap.Logger {

func newLogger(cfg *LoggerConfig) *zap.Logger {
if len(cfg.Filename) == 0 {
return debugLogger(cfg.Options.ZapOpts...)
return debugLogger()
}

ec := zap.NewProductionEncoderConfig()
Expand Down

0 comments on commit 1d90132

Please sign in to comment.