Skip to content

Commit

Permalink
feat: add bcs-task mysql store add createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
ifooth committed Oct 24, 2024
1 parent 14ff909 commit c41a4a6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions bcs-common/common/task/stores/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ import (
)

type mysqlStore struct {
dsn string
showDebug bool
db *gorm.DB
dsn string
debug bool
db *gorm.DB
}

type option func(*mysqlStore)

// ShowDebug 是否显示sql语句
func ShowDebug(showDebug bool) option {
// WithDebug 是否显示sql语句
func WithDebug(debug bool) option {
return func(s *mysqlStore) {
s.showDebug = showDebug
s.debug = debug
}
}

// New init mysql iface.Store
func New(dsn string, opts ...option) (iface.Store, error) {
store := &mysqlStore{dsn: dsn, showDebug: false}
store := &mysqlStore{dsn: dsn, debug: false}
for _, opt := range opts {
opt(store)
}

// 是否显示sql语句
level := logger.Warn
if store.showDebug {
if store.debug {
level = logger.Info
}

Expand Down

0 comments on commit c41a4a6

Please sign in to comment.