Skip to content

Commit

Permalink
#18 log slow queries
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 16, 2019
1 parent 2bcb6af commit 81d112e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/pgtk/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ def exec(query, args = [], result = 0)
rows
end
end
@log.debug("#{sql}: #{(start - Time.now).round}ms / #{@conn.object_id}")
lag = start - Time.now
if lag < 1
@log.debug("#{sql}: #{lag.round}ms / #{@conn.object_id}")
else
@log.info("#{sql}: #{format('%.02f', lag)}s")
end
out
end
end
Expand Down

0 comments on commit 81d112e

Please sign in to comment.