views:

102

answers:

1

The default behavior seems to be printing large stack traces like

ArgumentError (too few arguments):
app/controllers/players_controller.rb:55:in `format'
app/controllers/players_controller.rb:55:in `create'
/dh/passenger/lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
/dh/passenger/lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:400:in `start_request_handler'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:351:in `handle_spawn_application'
/dh/passenger/lib/phusion_passenger/utils.rb:184:in `safe_fork'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:349:in `handle_spawn_application'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:163:in `start'
/dh/passenger/lib/phusion_passenger/railz/application_spawner.rb:209:in `start'
/dh/passenger/lib/phusion_passenger/spawn_manager.rb:262:in `spawn_rails_application'
/dh/passenger/lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
/dh/passenger/lib/phusion_passenger/spawn_manager.rb:256:in `spawn_rails_application'
/dh/passenger/lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
/dh/passenger/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/dh/passenger/lib/phusion_passenger/spawn_manager.rb:255:in `spawn_rails_application'
/dh/passenger/lib/phusion_passenger/spawn_manager.rb:154:in `spawn_application'
/dh/passenger/lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:352:in `__send__'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
/dh/passenger/lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

but I only want to see the stack trace from my app. In this case, it's the top 3 lines, which consist of the actual Error, and then the parts of my app. In this case I'd prefer to see this:

ArgumentError (too few arguments):
app/controllers/players_controller.rb:55:in `format'
app/controllers/players_controller.rb:55:in `create'

Is this possible?

A: 

If you use Rails >= 2.3, the answer is backtrace silencers http://afreshcup.com/home/2008/11/29/rails-23-backtrace-silencing.html.

From release notes:

Rails automatically adds silencers to get rid of the most common noise in a new application, and builds a config/backtrace_silencers.rb file to hold your own additions

If you use an earlier version of Rails, use http://github.com/thoughtbot/quietbacktrace.

Vlad Zloteanu