mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-03-25 08:55:47 +00:00
Merge pull request #7 from marshall-lee/fix_unsubscribing
Fix serious memory leak
This commit is contained in:
commit
6f76458171
1 changed files with 4 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ module GrapeLogging
|
|||
start_time
|
||||
|
||||
@db_duration = 0
|
||||
ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
||||
@subscription = ActiveSupport::Notifications.subscribe('sql.active_record') do |*args|
|
||||
event = ActiveSupport::Notifications::Event.new(*args)
|
||||
@db_duration += event.duration
|
||||
end if defined?(ActiveRecord)
|
||||
|
|
@ -15,12 +15,13 @@ module GrapeLogging
|
|||
|
||||
def after
|
||||
stop_time
|
||||
logger.info parameters(request, response)
|
||||
logger.info parameters
|
||||
ActiveSupport::Notifications.unsubscribe(@subscription) if @subscription
|
||||
nil
|
||||
end
|
||||
|
||||
protected
|
||||
def parameters(request, response)
|
||||
def parameters
|
||||
{
|
||||
path: request.path,
|
||||
params: request.params.to_hash,
|
||||
|
|
|
|||
Loading…
Reference in a new issue