Skip to content

Commit

Permalink
Add time to logging failed Exec
Browse files Browse the repository at this point in the history
fixes #1189
  • Loading branch information
jackc committed Apr 22, 2022
1 parent bb8c52f commit 097b6aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ func (c *Conn) Exec(ctx context.Context, sql string, arguments ...interface{}) (
commandTag, err := c.exec(ctx, sql, arguments...)
if err != nil {
if c.shouldLog(LogLevelError) {
c.log(ctx, LogLevelError, "Exec", map[string]interface{}{"sql": sql, "args": logQueryArgs(arguments), "err": err})
endTime := time.Now()
c.log(ctx, LogLevelError, "Exec", map[string]interface{}{"sql": sql, "args": logQueryArgs(arguments), "err": err, "time": endTime.Sub(startTime)})
}
return commandTag, err
}
Expand Down

0 comments on commit 097b6aa

Please sign in to comment.