Skip to content

Commit

Permalink
dbutil/log: add option to trace log all queries
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <sumner@beeper.com>
  • Loading branch information
sumnerevans committed Jun 23, 2023
1 parent d8b15c1 commit a29f052
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion util/dbutil/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ type zeroLogger struct {
type ZeroLogSettings struct {
CallerSkipFrame int
Caller bool

// TraceLogAllQueries specifies whether or not all queries should be logged
// at the TRACE level.
TraceLogAllQueries bool
}

func ZeroLogger(log zerolog.Logger, cfg ...ZeroLogSettings) DatabaseLogger {
Expand Down Expand Up @@ -125,7 +129,7 @@ func (z zeroLogger) QueryTiming(ctx context.Context, method, query string, args
if log.GetLevel() == zerolog.Disabled || log == zerolog.DefaultContextLogger {
log = z.l
}
if log.GetLevel() != zerolog.TraceLevel && duration < 1*time.Second {
if (!z.TraceLogAllQueries || log.GetLevel() != zerolog.TraceLevel) && duration < 1*time.Second {
return
}
if nrows > -1 {
Expand Down

0 comments on commit a29f052

Please sign in to comment.