Skip to content

Commit

Permalink
chore: log sql to debug level
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 6, 2024
1 parent 73f71d1 commit eaa719a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions dal/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ package dal

import (
"database/sql"
"log"
"os"

"github.com/trim21/errgo"
"go.uber.org/zap"
"gorm.io/driver/mysql"
"gorm.io/gorm"
gormLogger "gorm.io/gorm/logger"
Expand All @@ -33,7 +32,7 @@ func NewDB(conn *sql.DB, c config.AppConfig) (*gorm.DB, error) {
if c.Debug.Gorm {
logger.Info("enable gorm debug mode, will log all sql")
gLog = gormLogger.New(
log.New(os.Stdout, "\r\n", log.LstdFlags),
logger.StdAt(zap.DebugLevel),
gormLogger.Config{
LogLevel: gormLogger.Info,
IgnoreRecordNotFoundError: true,
Expand Down
4 changes: 2 additions & 2 deletions internal/collections/infra/mysql_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ func (r mysqlRepo) reCountSubjectCollection(ctx context.Context, subjectID model
}

return r.q.Transaction(func(tx *query.Query) error {
err := tx.DB().WithContext(ctx).Exec(`select interest_type as type, count(interest_type) as total
from chii_subject_interests
err := tx.DB().WithContext(ctx).Exec(`
select interest_type as type, count(interest_type) as total from chii_subject_interests
where interest_subject_id = ?
group by interest_type
`, subjectID).Scan(&counts).Error
Expand Down

0 comments on commit eaa719a

Please sign in to comment.