Permalink
Browse files

log Oink Action with controller#action information instead of Process…

…ing Users#show

to avoid clashing with rails default logging information
  • Loading branch information...
1 parent 063915c commit 08dc63b5d471ff12580136d6324735942db68f0b Eirik Dentz Sinclair & Noah Davis committed Apr 5, 2011
@@ -33,7 +33,7 @@ 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']
- @logger.info("Processing #{controller}##{action}")
+ @logger.info("Oink Action: #{controller}##{action}")
end
end
@@ -26,7 +26,7 @@ def print(output)
@pids[pid][:buffer] << line
end
- if line =~ /Processing ((\w+)#(\w+)) /
+ if line =~ /Oink Action: ((\w+)#(\w+))/
@pids[pid][:action] = $1
unless @pids[pid][:request_finished]
@@ -25,7 +25,7 @@ def print(output)
@pids[pid][:buffer] << line
end
- if line =~ /Processing ((\w+)#(\w+)) /
+ if line =~ /Oink Action: ((\w+)#(\w+))/
unless @pids[pid][:request_finished]
@pids[pid][:last_memory_reading] = -1
@@ -44,7 +44,7 @@ def call(env)
it "logs the action and controller" do
get "/no_pigs", {}, {'action_dispatch.request.parameters' => {'controller' => 'oinkoink', 'action' => 'piggie'}}
- log_output.string.should include("Processing oinkoink#piggie")
+ log_output.string.should include("Oink Action: oinkoink#piggie")
end
end
@@ -7,7 +7,7 @@ module Oink::Reports
it "should report actions which exceed the threshold once" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -20,7 +20,7 @@ module Oink::Reports
it "should not report actions which do not exceed the threshold" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 50 | User: 50
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -33,10 +33,10 @@ module Oink::Reports
it "should report actions which exceed the threshold multiple times" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -49,13 +49,13 @@ module Oink::Reports
it "should order actions by most exceeded" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -69,11 +69,11 @@ module Oink::Reports
it "should not be bothered by incomplete requests" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 24 | User: 24
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -90,7 +90,7 @@ module Oink::Reports
it "should only report requests over threshold" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -103,7 +103,7 @@ module Oink::Reports
it "should not include requests which are not over threshold" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 50 | User: 50
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -116,27 +116,27 @@ module Oink::Reports
it "should order offenses from biggest to smallest" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing DetailsController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Details#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 75 | User: 75
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
io = StringIO.new(str)
output = PsuedoOutput.new
ActiveRecordInstantiationReport.new(io, 50).print(output)
- output[4].should == "1. Feb 01 01:58:34, 100, MediaController#show"
- output[5].should == "2. Feb 01 01:58:31, 75, DetailsController#show"
+ output[4].should == "1. Feb 01 01:58:34, 100, Media#show"
+ output[5].should == "2. Feb 01 01:58:31, 75, Details#show"
end
end
describe "verbose format" do
it "should print the full lines of actions exceeding the threshold" do
str = <<-STR
- Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -148,11 +148,11 @@ module Oink::Reports
it "should handle actions which do not complete properly" do
str = <<-STR
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 24 | User: 24
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Media#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
- Feb 01 01:58:29 ey04-s00297 rails[4413]: Processing Users#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Media#show
+ Feb 01 01:58:29 ey04-s00297 rails[4413]: Oink Action: Users#show
Feb 01 01:58:30 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 51 | User: 51
Feb 01 01:58:31 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -168,13 +168,13 @@ module Oink::Reports
it "should accept multiple files" do
str1 = <<-STR
- Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
str2 = <<-STR
- Feb 01 01:58:32 ey04-s00297 rails[4413]: Processing MediaController#show (for 92.84.151.171 at 2009-02-01 01:58:29) [GET]
+ Feb 01 01:58:32 ey04-s00297 rails[4413]: Oink Action: Media#show
Feb 01 01:58:33 ey04-s00297 rails[4413]: Instantiation Breakdown: Total: 100 | User: 100
Feb 01 01:58:34 ey04-s00297 rails[4413]: Oink Log Entry Complete
STR
@@ -183,7 +183,7 @@ module Oink::Reports
io2 = StringIO.new(str2)
output = PsuedoOutput.new
ActiveRecordInstantiationReport.new([io1, io2], 50).print(output)
- output.should include("2, MediaController#show")
+ output.should include("2, Media#show")
end
end
Oops, something went wrong. Retry.

0 comments on commit 08dc63b

Please sign in to comment.