lower log level for frequent messages

This commit is contained in:
Pay Giesselmann
2023-06-20 15:47:38 +02:00
parent d0516f12b0
commit a9544f5609
8 changed files with 29 additions and 29 deletions

View File

@@ -16,13 +16,13 @@ type Hooks struct{}
// Before hook will print the query with it's args and return the context with the timestamp
func (h *Hooks) Before(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
log.Infof("SQL query %s %q", query, args)
log.Debugf("SQL query %s %q", query, args)
return context.WithValue(ctx, "begin", time.Now()), nil
}
// After hook will get the timestamp registered on the Before hook and print the elapsed time
func (h *Hooks) After(ctx context.Context, query string, args ...interface{}) (context.Context, error) {
begin := ctx.Value("begin").(time.Time)
log.Infof("Took: %s\n", time.Since(begin))
log.Debugf("Took: %s\n", time.Since(begin))
return ctx, nil
}