indy 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +18 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/History.txt +11 -0
- data/README.md +132 -0
- data/Rakefile +68 -0
- data/autotest/discover.rb +2 -0
- data/cucumber.yml +6 -0
- data/features/after_time.feature +41 -0
- data/features/application.feature +33 -0
- data/features/around_time.feature +34 -0
- data/features/before_time.feature +34 -0
- data/features/custom_pattern.feature +52 -0
- data/features/exact_log_level.feature +35 -0
- data/features/exact_message.feature +33 -0
- data/features/exact_mulitple_fields.feature +38 -0
- data/features/exact_time.feature +28 -0
- data/features/file.feature +30 -0
- data/features/log_levels.feature +40 -0
- data/features/message.feature +39 -0
- data/features/multiple_fields.feature +38 -0
- data/features/step_definitions/find_by.steps.rb +55 -0
- data/features/step_definitions/log_file.steps.rb +8 -0
- data/features/step_definitions/support/env.rb +1 -0
- data/features/step_definitions/support/transforms.rb +28 -0
- data/features/step_definitions/test_setup.steps.rb +4 -0
- data/features/step_definitions/test_teardown.steps.rb +0 -0
- data/features/step_definitions/time.steps.rb +29 -0
- data/features/within_time.feature +41 -0
- data/indy.gemspec +61 -0
- data/lib/indy.rb +5 -0
- data/lib/indy/indy.rb +463 -0
- data/lib/indy/result_set.rb +8 -0
- data/performance/helper.rb +5 -0
- data/performance/profile_spec.rb +35 -0
- data/spec/data.log +2 -0
- data/spec/helper.rb +4 -0
- data/spec/indy_spec.rb +212 -0
- data/spec/result_set_spec.rb +9 -0
- data/spec/search_spec.rb +97 -0
- data/spec/time_spec.rb +80 -0
- metadata +126 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
@log_level
|
2
|
+
Feature: Finding log entries at an exact log level
|
3
|
+
As an Indy user I am able to create an instance and find all logs at the various standard log levels.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 DEBUG MyApp - Focusing application.
|
10
|
+
2000-09-07 14:07:43 DEBUG MyApp - Blurring application.
|
11
|
+
2000-09-07 14:07:44 WARN MyApp - Low on Memory.
|
12
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
13
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Count of entries at specified log level
|
17
|
+
When searching the log for the log severity INFO
|
18
|
+
Then I expect to have found 2 log entries
|
19
|
+
|
20
|
+
|
21
|
+
Scenario: Particular entry at the specified log level
|
22
|
+
When searching the log for the log severity INFO
|
23
|
+
Then I expect the first entry to be:
|
24
|
+
"""
|
25
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
26
|
+
"""
|
27
|
+
And I expect the last entry to be:
|
28
|
+
"""
|
29
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
30
|
+
"""
|
31
|
+
|
32
|
+
|
33
|
+
Scenario: No entries at the specified log level
|
34
|
+
When searching the log for the log severity SEVERE
|
35
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,33 @@
|
|
1
|
+
@message
|
2
|
+
Feature: Finding log entries exactly matching a message
|
3
|
+
As an Indy user I am able to create an instance and find all logs that exactly match a message.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:41 INFO MyApp - Exiting application.
|
10
|
+
"""
|
11
|
+
|
12
|
+
|
13
|
+
Scenario: Count of entries that exactly match the given message
|
14
|
+
When searching the log for the exact match of the message "Entering application."
|
15
|
+
Then I expect to have found 1 log entry
|
16
|
+
|
17
|
+
|
18
|
+
Scenario: Particular entry that exactly matches a given message
|
19
|
+
When searching the log for the exact match of the message "Entering application."
|
20
|
+
Then I expect the first entry to be:
|
21
|
+
"""
|
22
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
23
|
+
"""
|
24
|
+
|
25
|
+
|
26
|
+
Scenario: No entries when no messages exactly match
|
27
|
+
When searching the log for the exact match of the message "Opening application."
|
28
|
+
Then I expect to have found no log entries
|
29
|
+
|
30
|
+
|
31
|
+
Scenario: No entries when even when there is a partial match
|
32
|
+
When searching the log for the exact match of the message "application"
|
33
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,38 @@
|
|
1
|
+
@application @message @log_level @time
|
2
|
+
Feature: Finding log entries that exactly match multiple fields
|
3
|
+
As an Indy user I am able to create an instance and find all logs related to a particular application.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 DEBUG MyApp - Focusing application.
|
10
|
+
2000-09-07 14:07:43 DEBUG MyApp - Blurring application.
|
11
|
+
2000-09-07 14:07:44 WARN MyApp - Low on Memory.
|
12
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
13
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Count of entries that exactly match the application and log level
|
17
|
+
When searching the log for:
|
18
|
+
| application | severity |
|
19
|
+
| MyApp | DEBUG |
|
20
|
+
Then I expect to have found 2 log entries
|
21
|
+
|
22
|
+
|
23
|
+
Scenario: Particular entry that exactly match a message and and a log level
|
24
|
+
When searching the log for:
|
25
|
+
| Message | severity |
|
26
|
+
| Out of Memory. | ERROR |
|
27
|
+
Then I expect to have found 1 log entry
|
28
|
+
And I expect the first entry to be:
|
29
|
+
"""
|
30
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
31
|
+
"""
|
32
|
+
|
33
|
+
|
34
|
+
Scenario: No entries for when looking at a matching time but not exact message
|
35
|
+
When searching the log for:
|
36
|
+
| time | message |
|
37
|
+
| 2000-09-07 14:07:46 | Focusing application. |
|
38
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,28 @@
|
|
1
|
+
@time
|
2
|
+
Feature: Finding log messages at a particular time
|
3
|
+
As an Indy user I am able to create an instance and find all logs at an exact time.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 INFO MyApp - Exiting application.
|
10
|
+
"""
|
11
|
+
|
12
|
+
|
13
|
+
Scenario: Count of entries at the specified time
|
14
|
+
When searching the log for the time 2000-09-07 14:07:41
|
15
|
+
Then I expect to have found 1 log entry
|
16
|
+
|
17
|
+
|
18
|
+
Scenario: Particular entry at the specified time
|
19
|
+
When searching the log for the time 2000-09-07 14:07:41
|
20
|
+
Then I expect the last entry to be:
|
21
|
+
"""
|
22
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
23
|
+
"""
|
24
|
+
|
25
|
+
|
26
|
+
Scenario: No entries at the specified time
|
27
|
+
When searching the log for the time 2000-09-07 14:07:40
|
28
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,30 @@
|
|
1
|
+
@application
|
2
|
+
Feature: Finding log entries in a file
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given the following log:
|
6
|
+
"""
|
7
|
+
spec/data.log
|
8
|
+
"""
|
9
|
+
|
10
|
+
|
11
|
+
Scenario: Count of entries for a specific application
|
12
|
+
When searching the log for the application 'MyApp'
|
13
|
+
Then I expect to have found 2 log entries
|
14
|
+
|
15
|
+
|
16
|
+
Scenario: Particular entry for a specific application
|
17
|
+
When searching the log for the application 'MyApp'
|
18
|
+
Then I expect the first entry to be:
|
19
|
+
"""
|
20
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
21
|
+
"""
|
22
|
+
Then I expect the last entry to be:
|
23
|
+
"""
|
24
|
+
2000-09-07 14:07:41 INFO MyApp - Exiting application.
|
25
|
+
"""
|
26
|
+
|
27
|
+
|
28
|
+
Scenario: No entries for a specific application
|
29
|
+
When searching the log for the application 'YourApp'
|
30
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,40 @@
|
|
1
|
+
@log_level
|
2
|
+
Feature: Finding log entries at various log levels
|
3
|
+
As an Indy user I am able to create an instance and find all logs at or above the log level.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 DEBUG MyApp - Focusing application.
|
10
|
+
2000-09-07 14:07:43 DEBUG MyApp - Blurring application.
|
11
|
+
2000-09-07 14:07:44 WARN MyApp - Low on Memory.
|
12
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
13
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Count of messages at a specified log level or higher
|
17
|
+
When searching the log for the log severity INFO and higher
|
18
|
+
Then I expect to have found 4 log entries
|
19
|
+
|
20
|
+
|
21
|
+
Scenario: Count of messages at a specified log level or higher
|
22
|
+
When searching the log for the log severity DEBUG and higher
|
23
|
+
Then I expect to have found 6 log entries
|
24
|
+
|
25
|
+
|
26
|
+
Scenario: Count of messages at a specified log level or lower
|
27
|
+
When searching the log for the log severity INFO and lower
|
28
|
+
Then I expect to have found 4 log entries
|
29
|
+
|
30
|
+
|
31
|
+
Scenario: Particular message at a specified log level or higher
|
32
|
+
When searching the log for the log severity INFO and higher
|
33
|
+
Then I expect the first entry to be:
|
34
|
+
"""
|
35
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
36
|
+
"""
|
37
|
+
And I expect the last entry to be:
|
38
|
+
"""
|
39
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
40
|
+
"""
|
@@ -0,0 +1,39 @@
|
|
1
|
+
@message
|
2
|
+
Feature: Finding log messages by message
|
3
|
+
As an Indy user I am able to create an instance and find all logs related to a particular message or portion of a message.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:41 INFO MyApp - Exiting application.
|
10
|
+
"""
|
11
|
+
|
12
|
+
|
13
|
+
Scenario: Count of entries that partially match a given message
|
14
|
+
When searching the log for matches of the message "Entering"
|
15
|
+
Then I expect to have found 1 log entry
|
16
|
+
|
17
|
+
|
18
|
+
Scenario: Particular entry that partially match a given message
|
19
|
+
When searching the log for matches of the message "Entering"
|
20
|
+
Then I expect the first entry to be:
|
21
|
+
"""
|
22
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
23
|
+
"""
|
24
|
+
|
25
|
+
Scenario: Two entries that partially match a given message
|
26
|
+
When searching the log for matches of the message "application"
|
27
|
+
Then I expect the first entry to be:
|
28
|
+
"""
|
29
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
30
|
+
"""
|
31
|
+
Then I expect the last entry to be:
|
32
|
+
"""
|
33
|
+
2000-09-07 14:07:41 INFO MyApp - Exiting application.
|
34
|
+
"""
|
35
|
+
|
36
|
+
|
37
|
+
Scenario: No entries when no entries partially match the message
|
38
|
+
When searching the log for matches of the message "Opening"
|
39
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,38 @@
|
|
1
|
+
@application @message @log_level @time
|
2
|
+
Feature: Finding log entries that match multiple fields
|
3
|
+
As an Indy user I am able to create an instance and find all logs related to a particular application.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 DEBUG MyApp - Focusing application.
|
10
|
+
2000-09-07 14:07:43 DEBUG MyApp - Blurring application.
|
11
|
+
2000-09-07 14:07:44 WARN MyApp - Low on Memory.
|
12
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
13
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
14
|
+
"""
|
15
|
+
|
16
|
+
Scenario: Count of entries that partially matches the message and the log level
|
17
|
+
When searching the log for entries like:
|
18
|
+
| message | severity |
|
19
|
+
| application | INFO\|DEBUG |
|
20
|
+
Then I expect to have found 4 log entries
|
21
|
+
|
22
|
+
|
23
|
+
Scenario: Particular entry that partially matches two message but only one log level
|
24
|
+
When searching the log for entries like:
|
25
|
+
| Message | severity |
|
26
|
+
| [Mm]emory | ERROR |
|
27
|
+
Then I expect to have found 1 log entry
|
28
|
+
And I expect the first entry to be:
|
29
|
+
"""
|
30
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
31
|
+
"""
|
32
|
+
|
33
|
+
|
34
|
+
Scenario: No entries for when looking at a matching time but no application
|
35
|
+
When searching the log for:
|
36
|
+
| time | application |
|
37
|
+
| 2000-09-07 14:07:46 | YourApp |
|
38
|
+
Then I expect to have found no log entries
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
When /^searching the log for the application '([^']+)'$/ do |name|
|
3
|
+
@results = @indy.for(:application => name)
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^searching the log for the log severity (\w+)$/ do |severity|
|
7
|
+
@results = @indy.for(:severity => severity)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^searching the log for the log severity (\w+) and lower$/ do |severity|
|
11
|
+
@results = @indy.severity(severity,:equal_and_below)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^searching the log for the log severity (\w+) and higher$/ do |severity|
|
15
|
+
@results = @indy.severity(severity,:equal_and_above)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^searching the log for the exact match of the message "([^"]+)"$/ do |message|
|
19
|
+
@results = @indy.for(:message => message)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^searching the log for matches of the message "([^"]+)"$/ do |message|
|
23
|
+
@results = @indy.like(:message => message)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^searching the log for:$/ do |fields|
|
27
|
+
fields.map_headers! {|header| header.is_a?(Symbol) ? header : header.downcase.gsub(/\s/,'_').to_sym }
|
28
|
+
@results = @indy.search(fields.hashes.first)
|
29
|
+
end
|
30
|
+
|
31
|
+
When /^searching the log for entries like:$/ do |fields|
|
32
|
+
fields.map_headers! {|header| header.is_a?(Symbol) ? header : header.downcase.gsub(/\s/,'_').to_sym }
|
33
|
+
@results = @indy.matching(fields.hashes.first)
|
34
|
+
end
|
35
|
+
|
36
|
+
When /^searching the log for the exact match of custom field ([^"]+)\s*"([^"]+)"$/ do |field,value|
|
37
|
+
@results = @indy.search(field.strip.gsub(/\s/,'_').to_sym => value)
|
38
|
+
end
|
39
|
+
|
40
|
+
When /^searching the log for entries in the (\w+ \w+), by (.+)$/ do |portion, method|
|
41
|
+
method = method.intern
|
42
|
+
case portion
|
43
|
+
when /(second|last) half/
|
44
|
+
@results = @indy.last(:half, method)
|
45
|
+
when 'first half'
|
46
|
+
@results = @indy.first(:half, method)
|
47
|
+
else
|
48
|
+
pending
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
Then /^I expect the (first|last|\d+(?:st|nd|rd|th)) entry to be:$/ do |position,expected|
|
53
|
+
@results[position].line.should == expected
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../../lib/indy"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
Transform /^no$/ do |no|
|
3
|
+
0
|
4
|
+
end
|
5
|
+
|
6
|
+
Transform /^(\d+)$/ do |number|
|
7
|
+
number.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^I expect to have found (no|\d+) log entr(?:y|ies)$/ do |count|
|
11
|
+
@results.size.should == count
|
12
|
+
end
|
13
|
+
|
14
|
+
Transform /^first$/ do |order|
|
15
|
+
0
|
16
|
+
end
|
17
|
+
Transform /^last$/ do |order|
|
18
|
+
-1
|
19
|
+
end
|
20
|
+
|
21
|
+
Transform /^(\d+)(?:st|nd|rd|th)$/ do |order|
|
22
|
+
order.to_i - 1
|
23
|
+
end
|
24
|
+
|
25
|
+
# When searching the log for all entries after and including the time 2000-09-07 14:07:44
|
26
|
+
Transform /^ and including$/ do |inclusive|
|
27
|
+
true
|
28
|
+
end
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
When /^searching the log for the time (.+)$/ do |time|
|
3
|
+
@results = @indy.for(:time => time)
|
4
|
+
end
|
5
|
+
|
6
|
+
When /^searching the log for all entries after( and including)? the time (.+)$/ do |inclusive,time|
|
7
|
+
@results = @indy.after(:time => time, :inclusive => (inclusive ? true : false)).for(:all)
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^searching the log for all entries before( and including)? the time (.+)$/ do |inclusive,time|
|
11
|
+
@results = @indy.before(:time => time, :inclusive => (inclusive ? true : false)).for(:all)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^searching the log for all entries between( and including)? the times? (.+) and (.+)$/ do |inclusive,start,stop|
|
15
|
+
@results = @indy.within(:time => [start,stop], :inclusive => (inclusive ? true : false)).for(:all)
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^searching the log for all entries (\d+) minutes around( and including)? the time (.+)$/ do |time_span,inclusive,time|
|
19
|
+
@results = @indy.around(:time => time, :span => time_span, :inclusive => (inclusive ? true : false)).for(:all)
|
20
|
+
end
|
21
|
+
|
22
|
+
When /^searching the log for all entries (\d+) minutes after( and including)? the time (.+)$/ do |time_span,inclusive,time|
|
23
|
+
@results = @indy.after(:time => time, :span => time_span, :inclusive => (inclusive ? true : false)).for(:all)
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^searching the log for all entries (\d+) minutes before( and including)? the time (.+)$/ do |time_span,inclusive,time|
|
27
|
+
@results = @indy.before(:time => time, :span => time_span, :inclusive => (inclusive ? true : false)).for(:all)
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
@time @within
|
2
|
+
Feature: Finding log messages within a particular time
|
3
|
+
As an Indy user I am able to find all log messages that have happened between two specified times
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given the following log:
|
7
|
+
"""
|
8
|
+
2000-09-07 14:07:41 INFO MyApp - Entering application.
|
9
|
+
2000-09-07 14:07:42 DEBUG MyApp - Focusing application.
|
10
|
+
2000-09-07 14:07:43 DEBUG MyApp - Blurring application.
|
11
|
+
2000-09-07 14:07:44 WARN MyApp - Low on Memory.
|
12
|
+
2000-09-07 14:07:45 ERROR MyApp - Out of Memory.
|
13
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
14
|
+
"""
|
15
|
+
|
16
|
+
|
17
|
+
Scenario: Count of entries between the specified times
|
18
|
+
When searching the log for all entries between the time 2000-09-07 14:07:44 and 2000-09-07 14:07:46
|
19
|
+
Then I expect to have found 1 log entries
|
20
|
+
|
21
|
+
Scenario: Count of entries between and including the specified times
|
22
|
+
When searching the log for all entries between and including the times 2000-09-07 14:07:44 and 2000-09-07 14:07:46
|
23
|
+
Then I expect to have found 3 log entries
|
24
|
+
|
25
|
+
|
26
|
+
Scenario: Count of entries between the specified times
|
27
|
+
When searching the log for all entries between the time 2000-09-07 14:07:40 and 2000-09-07 14:07:50
|
28
|
+
Then I expect to have found 6 log entries
|
29
|
+
|
30
|
+
|
31
|
+
Scenario: Particular entry between the specified times
|
32
|
+
When searching the log for all entries between the time 2000-09-07 14:07:40 and 2000-09-07 14:07:50
|
33
|
+
Then I expect the last entry to be:
|
34
|
+
"""
|
35
|
+
2000-09-07 14:07:46 INFO MyApp - Exiting application.
|
36
|
+
"""
|
37
|
+
|
38
|
+
|
39
|
+
Scenario: No entries between the specified times
|
40
|
+
When searching the log for all entries between the time 2000-09-07 14:07:50 and 2000-09-07 14:07:55
|
41
|
+
Then I expect to have found no log entries
|