Closed yar closed 13 years ago
I believe it's a bug if it's not working on 2.3.x. The culprit is here, which checks the environment for a key named "action_dispatch.request.parameters", which I guess did not exist in 2.3.x.
If you happen to know a better environment variable to check for, preferably one that works on both 2.3.x and 3.x I can patch that.
Here you go:
diff --git a/lib/oink/middleware.rb b/lib/oink/middleware.rb
index f69c015..81346f7 100644
--- a/lib/oink/middleware.rb
+++ b/lib/oink/middleware.rb
@@ -28,9 +28,9 @@ module Oink
end
def log_routing(env)
- if env.has_key?('action_dispatch.request.parameters')
- controller = env['action_dispatch.request.parameters']['controller']
- action = env['action_dispatch.request.parameters']['action']
+ if env.has_key?(key = 'action_dispatch.request.parameters') || env.has_key?(key = 'action_controller.request.path_parameters')
+ controller = env[key]['controller']
+ action = env[key]['action']
@logger.info("Oink Action: #{controller}##{action}")
end
end
(I deleted and resubmitted the comment because one of the lines was truncated.)
Thanks for noting the issue and for the patch.
Great! Kudos for the expressive self-documenting syntax.
Hi
I am trying to use Oink 0.9.2 and hodel_3000_compliant_logger 0.1.0, as gems, under rails 2.3.11.
In environment.rb:
Rails::Initializer.run do |config| require 'hodel_3000_compliant_logger' config.logger = h3_log = Hodel3000CompliantLogger.new(config.log_path) config.middleware.use "Oink::Middleware", :logger => h3_log ... end
This is what I am getting in log/development.log:
Jul 08 17:09:09 yarmac rails[29643]: Completed in 582ms (View: 194, DB: 21) | 200 OK [http://weather.local/] Jul 08 17:09:09 yarmac rails[29643]: Memory usage: 2561680 | PID: 29643 Jul 08 17:09:09 yarmac rails[29643]: Instantiation Breakdown: Total: 14 | Photo: 6 | Location: 5 | Weatherfinder: 1 | Forecast: 1 | Language: 1 Jul 08 17:09:09 yarmac rails[29643]: Oink Log Entry Complete
No "Oink Action" line!
If I then run
% oink --threshold=0 log/development.log
---- MEMORY THRESHOLD ---- THRESHOLD: 0 MB
-- SUMMARY -- Worst Requests:
Worst Actions: 44, %
– the result is missing the action list as well.
Is Rails 2.3.11 still supported?