Skip to content

Instantly share code, notes, and snippets.

@mwlang
Last active August 29, 2015 14:22
Show Gist options
  • Save mwlang/a72550bea798482e5eab to your computer and use it in GitHub Desktop.
Save mwlang/a72550bea798482e5eab to your computer and use it in GitHub Desktop.
Scans a Rails 1.2 Log file for controller actions. Logs IP Address, verb of the action, session id, and the parameters passed. Using this to build up a training database for Prediction IO
require 'sequel'
DB = Sequel.mysql2('historical_events', user: 'root', host: "localhost")
unless DB.tables.include? :events
DB.create_table :events do
primary_key :id
String :ip_address
String :session
String :action
String :verb
String :params, :size => 4096
end
else
DB[:events].delete
end
log_path = File.dirname(File.expand_path(__FILE__))
data = File.read(File.join(log_path, 'p.log'), encoding: "utf-8")
processing_line = '(^Processing)*?Processing\s([\w|#]+)\s\(for\s([\d|\.]+)[^\)]+\)\s\[(\w+)\]\r?\n'
session_line = '\s+Session\sID\:\s(\w+)\r?\n'
params_line = '\s+Parameters\:\s([^\r?\n]+)\r?\n'
matcher = /(#{processing_line}#{session_line}#{params_line})+/m
data.scan(matcher).each do |values|
values.shift
attributes = {
action: values[1],
ip_address: values[2],
verb: values[3],
session: values[4],
params: values[5]
}
DB[:events].insert attributes
puts attributes.inspect
end
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"4cea3d757bd9ddd6fa8cb2b0b34486e8", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"Detaljer\", \"9780007284870\"]}"}
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"58520ea2c9ef9bf5963890673fabadf3", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"error_page\"]}"}
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"cf97aecfc0a03e11265def6b6d6e33cb", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"Detaljer\", \"9780071222105\"]}"}
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"ba11b76703006a4b3cece06b206ff2ad", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"error_page\"]}"}
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"172b7f4130f5788bbd563cdccec7cd0c", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"Detaljer\", \"9788757427585\"]}"}
{:action=>"ContentController#index", :ip_address=>"188.40.109.147", :verb=>"GET", :session=>"28fae8088620dc63e30fed9e7b5ccd39", :params=>"{\"action\"=>\"index\", \"controller\"=>\"content\", \"absolute_url\"=>[\"home\", \"error_page\"]}"}
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in `perform_action'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:430:in `send'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:430:in `process_without_filters'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in `process'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:330:in `process'
#{RAILS_ROOT}/vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/rails.rb:76:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/rails.rb:74:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/rails.rb:74:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:159:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:158:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:158:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:285:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:285:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:268:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:268:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel.rb:268:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/configurator.rb:282:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/configurator.rb:281:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/configurator.rb:281:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/bin/mongrel_rails:128:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/lib/mongrel/command.rb:212:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.3-i386-mswin32/bin/mongrel_rails:281
c:/ruby/bin/mongrel_rails:16:in `load'
c:/ruby/bin/mongrel_rails:16
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:08) [GET]
Session ID: 65003f6ead573b497221520aa1188c19
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780006544890"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:11) [GET]
Session ID: 4cea3d757bd9ddd6fa8cb2b0b34486e8
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780007284870"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 0.51600 (1 reqs/sec) | DB: 0.17400 (33%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9780007284870]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:15) [GET]
Session ID: 58520ea2c9ef9bf5963890673fabadf3
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 1.25000 (0 reqs/sec) | Rendering: 0.46900 (37%) | DB: 0.31300 (25%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:18) [GET]
Session ID: ad589fea1c6c1e2021a11fb45041675a
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780070311183"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:22) [GET]
Session ID: cf97aecfc0a03e11265def6b6d6e33cb
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780071222105"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 1.25000 (0 reqs/sec) | DB: 0.35800 (28%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9780071222105]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:29) [GET]
Session ID: ba11b76703006a4b3cece06b206ff2ad
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 1.48400 (0 reqs/sec) | Rendering: 0.54800 (36%) | DB: 0.46800 (31%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:32) [GET]
Session ID: c349d97666d642be45ed31f522888164
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780071222150"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:34) [GET]
Session ID: f9fb695ac9150dd065d6a67bb0d30e09
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788750209966"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:35) [GET]
Session ID: 172b7f4130f5788bbd563cdccec7cd0c
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788757427585"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 0.46900 (2 reqs/sec) | DB: 0.11100 (23%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9788757427585]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:37) [GET]
Session ID: 28fae8088620dc63e30fed9e7b5ccd39
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 0.14000 (7 reqs/sec) | Rendering: 0.03100 (22%) | DB: 0.09400 (67%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 157.55.39.245 at 2015-05-23 10:30:38) [GET]
Session ID: 404272b9b9e738d85d91780749ceb4fd
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788750210184"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:42) [GET]
Session ID: cf978ad445db884c8f42cbcad493b989
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788757430660"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 1.17200 (0 reqs/sec) | DB: 0.26700 (22%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9788757430660]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:48) [GET]
Session ID: 862901445a7020e77eaa7aa991317e94
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 1.23400 (0 reqs/sec) | Rendering: 0.54800 (44%) | DB: 0.23300 (18%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:54) [GET]
Session ID: 82fc14012b6904a4eca062d4cce6da9d
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788757483277"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 1.09400 (0 reqs/sec) | DB: 0.20600 (18%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9788757483277]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:30:58) [GET]
Session ID: f543f5a8c71e1b3bc7a33a7ccca86788
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 0.37500 (2 reqs/sec) | Rendering: 0.25000 (66%) | DB: 0.14100 (37%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:31:01) [GET]
Session ID: c3a9a0dee24b871d2bfdbb0c7d2115f1
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788759313558"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:31:05) [GET]
Session ID: 06f6814674abc53918d85fea3871aa4b
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788761934727"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 1.14100 (0 reqs/sec) | DB: 0.37600 (32%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9788761934727]
Processing ContentController#index (for 5.9.94.207 at 2015-05-23 10:31:07) [GET]
Session ID: 975302feb0b16adece876d25f8604fdc
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9780715638330"]}
Processing ContentController#index (for 188.40.109.147 at 2015-05-23 10:31:09) [GET]
Session ID: 65beb5317a3506a42508939581a4cb76
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "error_page"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 0.42200 (2 reqs/sec) | Rendering: 0.17200 (40%) | DB: 0.21800 (51%) | 200 OK [http://www.polyteknisk.dk/home/error_page]
Processing ContentController#index (for 157.55.39.245 at 2015-05-23 10:31:57) [GET]
Session ID: 7bd9b26f03f5df2d1e17099c9ee8f4d5
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "Detaljer", "9788779551947"]}
Redirected to http://www.polyteknisk.dk/home/error_page
Completed in 1.10900 (0 reqs/sec) | DB: 0.40500 (36%) | 302 Found [http://www.polyteknisk.dk/home/Detaljer/9788779551947]
Processing ContentController#index (for 80.213.57.73 at 2015-05-23 10:33:26) [GET]
Session ID: 5be8709c0d233e6baf258c142263e0d1
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "nautilus"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Processing ContentController#index (for 220.181.108.99 at 2015-05-23 10:34:44) [GET]
Session ID: aa836377916ca3677683fd54eb56037e
Parameters: {"action"=>"index", "controller"=>"content"}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
Completed in 1.96900 (0 reqs/sec) | Rendering: 1.10800 (56%) | DB: 0.70600 (35%) | 200 OK [http://www.polyteknisk.dk/]
Processing ContentController#index (for 80.213.57.73 at 2015-05-23 10:34:46) [GET]
Session ID: cd5f94d798aea26e99f4551ed78aa0b3
Parameters: {"action"=>"index", "controller"=>"content", "absolute_url"=>["home", "nautilus"]}
Rendering layoutfalseactionpage within layouts/store
Rendering content/page
ActionView::TemplateError (NoMemoryError: failed to allocate memory: 'SELECT * FROM items WHERE (items.[id] = 9788790924546) ') on line #7 of app/views/content_providers/shared/_list_item_normal.rhtml:
4: item = []
5: item = list_item.is_a?(Item) ? list_item : Item.find_by_id(list_item.id)
6: customer_price= (customer_pricing item).to_f
7: item_type = Item.find(item.id).item_type
8: %>
9:
10: <%
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:129:in `log'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb:332:in `execute'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb:516:in `select'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:427:in `find_by_sql'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:997:in `find_every'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1028:in `find_one'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:1014:in `find_from_ids'
#{RAILS_ROOT}/vendor/rails/activerecord/lib/active_record/base.rb:419:in `find'
#{RAILS_ROOT}/app/views//content_providers/shared/_list_item_normal.rhtml:7:in `_run_rhtml_47app47views47content_providers47shared47_list_item_normal46rhtml'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `send'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `compile_and_render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in `render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render_file'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:275:in `render'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:59:in `render_partial'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:30:in `benchmark'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:58:in `render_partial'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:287:in `render'
#{RAILS_ROOT}/app/views//content_providers/shared/_items_lister.rhtml:44:in `_run_rhtml_47app47views47content_providers47shared47_items_lister46rhtml'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:59:in `each_with_index'
#{RAILS_ROOT}/app/views//content_providers/shared/_items_lister.rhtml:34:in `each'
#{RAILS_ROOT}/app/views//content_providers/shared/_items_lister.rhtml:34:in `each_with_index'
#{RAILS_ROOT}/app/views//content_providers/shared/_items_lister.rhtml:34:in `_run_rhtml_47app47views47content_providers47shared47_items_lister46rhtml'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:108:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:108:in `capture_erb_with_buffer'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb:67:in `capture'
#{RAILS_ROOT}/app/helpers/application_helper.rb:168:in `content_box'
#{RAILS_ROOT}/app/views//content_providers/shared/_items_lister.rhtml:11:in `_run_rhtml_47app47views47content_providers47shared47_items_lister46rhtml'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `send'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `compile_and_render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in `render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render_file'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:275:in `render'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:59:in `render_partial'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:30:in `benchmark'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/partials.rb:58:in `render_partial'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:287:in `render'
#{RAILS_ROOT}/app/views/content/page.rhtml:18:in `_run_rhtml_47app47views47content47page46rhtml'
#{RAILS_ROOT}/app/views/content/page.rhtml:15:in `each'
#{RAILS_ROOT}/app/views/content/page.rhtml:15:in `_run_rhtml_47app47views47content47page46rhtml'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `send'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in `compile_and_render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in `render_template'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in `render_file'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in `render_file'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:738:in `render_with_no_layout'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:863:in `render_without_layout'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:798:in `render_action'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:748:in `render_with_no_layout'
#{RAILS_ROOT}/vendor/rails/activesupport/lib/active_support/deprecation.rb:44:in `silence'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:747:in `render_with_no_layout'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:244:in `render_without_benchmark'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in `render'
#{RAILS_ROOT}/app/controllers/content_controller.rb:28:in `index'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:1095:in `send'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:632:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:634:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
@havenwood
Copy link

Requisite Regexp-free solution:

data.split("\n\n").map do |request|
  next unless request.start_with? "\nProcessing"

  _, request_line, session_line, params_line = request.lines
  _, action, _, ip_address, *tail = request_line.split
  *_, verb = tail
  _, _, session = session_line.rpartition ' '
  _, _, params = params_line.strip.partition ' '

  {
    action: action,
    ip_address: ip_address,
    verb: verb.delete('[]'),
    session: session,
    params: params
  }
end.compact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment