Skip to content

Commit

Permalink
Reduce database log verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed Mar 13, 2024
1 parent 12311ee commit 785a012
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/icinga-kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ func main() {
return
}

dbLog.Info("Importing schema")

hasSchema, err := dbHasSchema(db, d.Database)
if err != nil {
klog.Fatal(err)
}

if !hasSchema {
dbLog.Info("Importing schema")

for _, ddl := range strings.Split(k8sMysql.Schema, ";") {
if ddl = strings.TrimSpace(ddl); ddl != "" {
if _, err := db.Exec(ddl); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,10 @@ func (db *Database) YieldAll(ctx context.Context, factoryFunc func() (interface{
func (db *Database) periodicLog(ctx context.Context, query string, counter *com.Counter) periodic.Stopper {
return periodic.Start(ctx, 10*time.Second, func(tick periodic.Tick) {
if count := counter.Reset(); count > 0 {
db.log.Info(fmt.Sprintf("Executed %s with %d rows", query, count))
db.log.V(2).Info(fmt.Sprintf("Executed %s with %d rows", query, count))
}
}, periodic.OnStop(func(tick periodic.Tick) {
db.log.Info(fmt.Sprintf("Finished executing %s with %d rows in %s", query, counter.Total(), tick.Elapsed))
db.log.V(2).Info(fmt.Sprintf("Finished executing %s with %d rows in %s", query, counter.Total(), tick.Elapsed))
}))
}

Expand Down

0 comments on commit 785a012

Please sign in to comment.