Skip to content

Commit

Permalink
allow for log lines with and without the db time
Browse files Browse the repository at this point in the history
  • Loading branch information
garethr committed Aug 18, 2012
1 parent 430c687 commit ab8c3cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion patterns/lograge
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LOGRAGE %{WORD:method}%{SPACE}%{DATA}%{SPACE}action=%{WORD:controller}#%{WORD:action}%{SPACE}status=%{INT:status}%{SPACE}duration=%{NUMBER:duration}%{SPACE}view=%{NUMBER:view}%{GREEDYDATA}
LOGRAGE %{WORD:method}%{SPACE}%{DATA}%{SPACE}action=%{WORD:controller}#%{WORD:action}%{SPACE}status=%{INT:status}%{SPACE}duration=%{NUMBER:duration}%{SPACE}view=%{NUMBER:view}(%{SPACE}db=%{NUMBER:db})?%{GREEDYDATA}
14 changes: 14 additions & 0 deletions spec/lograge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
@match.should have_logstash_field("controller").with_value("jobs")
@match.should have_logstash_field("action").with_value("show")
end

it "should have the correct value for db time" do
@match.should have_logstash_field("db").with_value("15.26")
end
end

describe "without the db time" do
before do
log_line = "GET /jobs/833552.json format=json action=jobs#show status=200 duration=58.33 view=40.43"
@match = @grok.match(log_line)
end
it "should have the correct value for the request view time" do
@match.should have_logstash_field("view").with_value("40.43")
end
end

describe "with a post request" do
Expand Down

0 comments on commit ab8c3cc

Please sign in to comment.