mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 15:23:14 -05:00
[FEAT] Don't log context cancelled SQL errors
- I found this while doing some unrelated testing in Forgejo. It wasn't my intention to log failed SQL queries if they were cancelled (which can happen quite frequently for larger instances) as in those cases it's not interesting to know which SQL query was run. My intentation was only to log an SQL query if there was an error reported by the database. - Ref #2140
This commit is contained in:
parent
c6a89b490d
commit
cbbcfdd400
1 changed files with 2 additions and 1 deletions
|
@ -7,6 +7,7 @@ package db
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
|
@ -342,7 +343,7 @@ func (ErrorQueryHook) BeforeProcess(c *contexts.ContextHook) (context.Context, e
|
|||
}
|
||||
|
||||
func (h *ErrorQueryHook) AfterProcess(c *contexts.ContextHook) error {
|
||||
if c.Err != nil {
|
||||
if c.Err != nil && !errors.Is(c.Err, context.Canceled) {
|
||||
h.Logger.Log(8, log.ERROR, "[Error SQL Query] %s %v - %v", c.SQL, c.Args, c.Err)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue