Skip to content
Snippets Groups Projects
Commit 20ab46e5 authored by Jano Hendriks's avatar Jano Hendriks
Browse files

Add ability to suppress individual DB logs

parent 1848948e
Branches
Tags v1.288.0
No related merge requests found
......@@ -30,6 +30,10 @@ var ignoredTableInserts = []string{
"revenue_rollup",
}
type ContextWithSuppressDBLog interface {
DoSuppressDBLog() bool
}
type QueryHook struct {
IgnoredTableInserts []string
Debug bool
......@@ -39,7 +43,14 @@ func (d QueryHook) BeforeQuery(ctx context.Context, _ *bun.QueryEvent) context.C
return ctx
}
func (d QueryHook) AfterQuery(_ context.Context, event *bun.QueryEvent) {
func (d QueryHook) AfterQuery(ctx context.Context, event *bun.QueryEvent) {
contextWithSuppressDBLog, ok := ctx.(ContextWithSuppressDBLog)
if ok {
if contextWithSuppressDBLog.DoSuppressDBLog() {
return
}
}
sqlQuery := event.Query
queryDuration := time.Now().Sub(event.StartTime)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment