Skip to content

Commit

Permalink
SqlCollector: enabled is true by default
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Aug 9, 2024
1 parent 1447f8d commit f8246ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ type SqlCollector struct {
sqls map[string]struct{}
}

// NewSqlCollector returns a new SqlCollector.
// NewSqlCollector returns a new SqlCollector with enabled==true.
func NewSqlCollector() *SqlCollector {
return &SqlCollector{sqls: make(map[string]struct{}, 128)}
return (&SqlCollector{sqls: make(map[string]struct{}, 128)}).SetEnabled(true)
}

// Sqls returns the executed sqls.
Expand Down
2 changes: 1 addition & 1 deletion interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

func TestSqlCollector(t *testing.T) {
collector := NewSqlCollector()
collector := NewSqlCollector().SetEnabled(false)
_, _, _ = collector.Intercept("sql0", nil)

collector.SetEnabled(true)
Expand Down

0 comments on commit f8246ca

Please sign in to comment.