indy 0.4.0.pre → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daf391715ba62b54e26aceed291bb60ca7e4b44c
4
- data.tar.gz: f02335c95b62f424f1325e87b95729da4d3c77ce
3
+ metadata.gz: 712e234a85c0ab55eeb8b1c47eb7cd0bad77ee55
4
+ data.tar.gz: 9a366319c64e9f7db69c777c4dc9f66776b26a29
5
5
  SHA512:
6
- metadata.gz: b5390c28c66aa47a30848e4fd72ea40753b8ae46cbc6c7f66b9f130c8adafbf9909e22d742f76271a311f48a21a3c4f416999de1cecda07485cf9c33a640ce6c
7
- data.tar.gz: 5a6328e2c45a0872098192d5a3c73224cd487c54838ab4b7524483182bbe9b4d3dcce521d7065e6ad4782a35e8da45deee988d076fb9b8167980ed8dcb2da4e5
6
+ metadata.gz: 33b4f8537e0c32a94e3cf654e461a3aace37d51c528b812b1f2308e04e1f857ce1d9d791ee7d6dbd378a02847c04dd45924d146e2789d63416f448969f3a3c23
7
+ data.tar.gz: c8cb0409964768cd728968feaa82f53852b161aca0ac65fee9ed872946aca7fd2ccc951948f2e0f486495408dc95693c0625ab0ff06f75547e0690fcf53d00a9
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.2.1
4
4
  - 1.9.3
5
- - jruby-19mode # JRuby in 1.9 mode
6
- - rbx-19mode
7
5
  - 1.8.7
8
- - ree
6
+ - ree
7
+ - rbx-2.2.7
8
+ - jruby-1.7.20
@@ -1,8 +1,15 @@
1
- === 0.4.0 / unreleased
1
+ === 0.5.0 / 2015-12-08
2
2
 
3
+ * Improved time format handling
4
+ * Multiline :entry_regexp now requires a capture group for the entire entry
3
5
  * Faster time scoped searches when using single line log formats
4
- * result[:entry] had replaced result[:line]
6
+ * result.raw_entry has replaced result.line
5
7
  * Indy#all has replaced Indy#for(:all)
8
+ * LogDefinition internal cleanup
9
+ * Restored support for Ruby 1.8.7
10
+
11
+ === 0.4.0.pre (unreleased)
12
+
6
13
 
7
14
  === 0.3.4 / 2011-08-07
8
15
 
data/README.md CHANGED
@@ -4,6 +4,8 @@ Indy: A Log Archaeology Tool
4
4
  Synopsis
5
5
  --------
6
6
 
7
+ [![build status](https://travis-ci.org/bfaloona/Indy.png)](http://travis-ci.org/bfaloona/Indy)
8
+
7
9
  Log files are often searched for particular strings but are not often treated as data structures. Indy attempts to deliver log content via more powerful features by allowing the ability to collect segments of a log from particular time; find a particular event; or monitor/reflect on a log to see if a particular event occurred (or not occurred).
8
10
 
9
11
  Installation
@@ -12,34 +14,36 @@ Installation
12
14
  To install Indy use the following command:
13
15
 
14
16
  $ gem install indy
15
-
16
- (Add `sudo` if you're installing under a POSIX system as root)
17
-
18
- Compatibility
19
- -------------
20
-
21
- [![build status](https://travis-ci.org/bfaloona/Indy.png)](http://travis-ci.org/bfaloona/Indy)
22
-
23
- Indy supports MacOS, *nix, and MS Windows and runs on the following ruby flavors:
24
-
25
- - 1.8.7
26
- - 1.9.3
27
- - 2.0.0
28
- - ree
29
- - jruby-19mode
30
- - rbx-19mode
31
17
 
32
18
  Usage
33
19
  -----
34
20
 
35
- ## Example
21
+ ## Basic Example (default log pattern)
22
+
23
+ log = Indy.search(:file => './data.log').all.first.message
24
+ # => "Entering APPLICATION."
36
25
 
37
- require 'indy'
38
- log = Indy.search(File.open('my_log.txt','r')).with(Indy::LOG4R_FORMAT)
39
- puts log.all.first.raw_entry
40
- # => "2012-09-07 10:01:40 INFO MyApp - Entering APPLICATION."
41
- puts log.after(:time => '2012-09-07 20:00:00').for(:application => 'MyApp').first.message
42
- # => "Exiting Application"
26
+ ## Custom Example
27
+
28
+ # Given this log file:
29
+ #
30
+ # 2015/09/08 INFO #index Indexing application.
31
+ # 2015/09/11 ERROR #search Searching application.
32
+ # ...
33
+
34
+ log_contents = File.open('./example.log', 'r').read
35
+ pattern = /^(\d{4}\/\d{2}\/\d{2})\s+(INFO|DEBUG|WARN|ERROR)\s+(#\S+)\s+(.+)$/
36
+ fields = [:time, :severity, :method, :message]
37
+ custom_time_format = '%Y/%m/%d'
38
+
39
+ indy = Indy.search( :source => log_contents,
40
+ :entry_regexp => pattern,
41
+ :entry_fields => fields,
42
+ :time_format => custom_time_format
43
+ )
44
+ indy.after(:time => '2015/09/10').like(:severity => 'ERROR') do |entry|
45
+ puts "#{entry.time} (#{entry.method}) #{entry.message}"
46
+ end
43
47
 
44
48
  ## Specify your Source
45
49
 
@@ -84,18 +88,21 @@ allowing searches like so:
84
88
 
85
89
  ### Custom Log Format
86
90
 
87
- If you have a different log format you can brew your own.
88
- To do so, specify a Regexp pattern that captures each field you want to reference.
89
- Include it as the first item of your log format array, followed by a list of symbols that name the captured fields.
91
+ Brew your own log format!
92
+ To do so, specify an `:entry_regexp` pattern that captures each field you want to reference.
93
+ Also, specify an `:entry_fields` array of symbols that name the fields captured by your regexp.
94
+ If your date/time format differs from the default (%Y-%m-%d %H:%M:%S), you will need to specify a `:time_format` parameter.
90
95
 
91
96
  # If your log format is:
92
- # HH:MM:SS SEVERITY APPLICATION#METHOD - MESSAGE
93
- # Build an appropriate regexp
94
- custom_regexp = /^(\d{2}:\d{2}:\d{2})\s*(INFO|DEBUG|WARN|ERROR)\s*([^#]+)#([^\s]+)\s*-\s*(.+)$/
95
- # Combine the pattern and the list of fields
96
- custom_log_format = [custom_regexp,:time,:severity,:application,:method,:message]
97
+ # YYYY-MM-DD HH:MM:SS SEVERITY APPLICATION#METHOD - MESSAGE
98
+
99
+ # Build a regexp pattern
100
+ pattern = /^(\d{4}.\d{2}.\d{2}\s+\d{2}.\d{2}.\d{2})\s*(INFO|DEBUG|WARN|ERROR)\s*([^#]+)#([^\s]+)\s*-\s*(.+)$/
101
+ # List the log fields
102
+ fields = [:time,:severity,:application,:method,:message]
103
+
97
104
  # Use Indy#with to define your format
98
- Indy.search(source).with(custom_log_format).for(:severity => 'INFO', :method => 'allocate')
105
+ Indy.search(source).with(:entry_regexp => pattern, :entry_fields => fields)
99
106
 
100
107
  ### Predefined Log Format
101
108
 
@@ -107,42 +114,52 @@ Several log formats have been predefined for ease of configuration. See indy/for
107
114
  #
108
115
  # Example (Log4r)
109
116
  # INFO mylog: This is a message with level INFO
110
- Indy.new(:source => log_file, :log_format => Indy::LOG4R_DEFAULT_FORMAT).for(:application => 'mylog')
117
+ Indy.new(:source => log_file).with(Indy::LOG4R_DEFAULT_FORMAT).for(:application => 'mylog')
111
118
 
112
119
  ### Multiline log entries
113
120
 
114
- By default, Indy assumes that log lines are separated by new lines. Any lines that don't match the active pattern are ignored. To enable multiline log entries you must do two things:
121
+ By default, Indy assumes that log lines are separated by new lines.
122
+ Any lines that don't match the active pattern are ignored.
123
+ To enable multiline log entries you MUST do these things:
115
124
 
116
125
  1. Use `Indy.new()` and include the `:multiline => true` parameter
117
126
  2. Use a log entry regexp that does not use `$` and/or `\n` to define the end of the entry.
127
+ 3. Add a capture group that surrounds one full log entry.
118
128
 
119
129
  #### Multiline Regexp tips
120
130
 
121
131
  * Use non-greedy matching when needed: `.*?` instead of `.*`
122
- * Assuming your log entries do not include a unique line ending, you can use a zero-width positive lookahead assertion to verify that each line is followed by the start of a valid log entry, or the end of the string. e.g.: `(?=^foo|\z)`
132
+ * Assuming your log entries do not include a unique line ending, you can use a zero-width positive lookahead assertion to verify that each line is followed by the start of a valid log entry, or the end of the string. e.g.: if 'foo' starts each entry, use this assertion `(?=^foo|\z)` at the end of your `:entry_regexp`
123
133
 
124
134
  Check out [Regexp Extensions](http://www.ruby-doc.org/docs/ProgrammingRuby/html/language.html#UN)
125
135
 
126
136
  Example:
127
137
 
128
- # Given this log containing two entries:
138
+ # Given this log containing three entries:
129
139
  #
130
140
  # INFO MyApp - Multiline message begins here...
131
141
  # and ends here
132
142
  # DEBUG MyOtherApp - Single line message.
133
- # WARN MyOtherApp - Another single line message.
143
+ # WARN MyOtherApp - A third entry.
134
144
 
135
145
  severity_string = 'DEBUG|INFO|WARN|ERROR|FATAL'
136
146
 
137
- # single line regexp would be:
147
+ multiline_regexp = /^((#{severity_string}) (\w+) - (.*?)(?=^#{severity_string}|\z))/
148
+
149
+ # For reference, a single line regexp would be:
138
150
  # /^(#{severity_string}) (\w+) - (.*)$/
139
- multiline_regexp = /^(#{severity_string}) (\w+) - (.*?)(?=^#{severity_string}|\z)/
140
151
 
141
- Indy.new( :multiline => true, :log_format => [multiline_regexp, :severity, :application, :message], :source => MY_LOG)
152
+
153
+ Indy.new( :multiline => true,
154
+ :entry_regexp => multiline_regexp,
155
+ :entry_fields => [:severity, :application, :message],
156
+ :source => MY_LOG
157
+ )
142
158
 
143
159
  ### Explicit Time Format
144
160
 
145
- By default, Indy tries to guess your time format (courtesy of DateTime#parse). If you supply an explicit time format, it will use DateTime#strptime, as well as try to guess.
161
+ If not specified, Indy tries to guess your time format (courtesy of DateTime#parse).
162
+ If you supply an explicit time format, it will use DateTime#strptime. If that fails, it will then guess with DateTime#parse.
146
163
 
147
164
  This is required when log data uses a non-standard date format, e.g.: U.S. format 12-31-2000, and must be used in
148
165
  conjunction with :entry_regexp and :entry_fields parameters.
@@ -152,7 +169,9 @@ conjunction with :entry_regexp and :entry_fields parameters.
152
169
  :source => LOG_FILE,
153
170
  :entry_regexp => /\d\d-\d\d-\d\d\d\d .*?/,
154
171
  :entry_fields => [:time, :message]
155
- ).all
172
+ ).all
173
+
174
+ Format directives are documented in [DateTime#strftime](http://ruby-doc.org/stdlib-2.0.0/libdoc/date/rdoc/DateTime.html#method-i-strftime).
156
175
 
157
176
  ## Match Criteria
158
177
 
@@ -176,7 +195,7 @@ conjunction with :entry_regexp and :entry_fields parameters.
176
195
 
177
196
  ## Log Scopes
178
197
 
179
- Multiple scope methods can be called on an instance. Use #reset_scope to remove scope constrints on the instance.
198
+ Multiple scope methods can be called on an instance. Use #reset_scope to remove scope constraints on the instance.
180
199
 
181
200
  ### Time Scope
182
201
 
@@ -206,11 +225,12 @@ Multiple scope methods can be called on an instance. Use #reset_scope to remove
206
225
 
207
226
  ## Process the Results
208
227
 
209
- A ResultSet is returned by #for and #like, which is an Enumerable containing a hash for each log entry.
228
+ An Array is returned by #for and #like, containing a Struct::Entry for each log entry.
229
+ The full entry is available with `entry.raw_entry`.
210
230
 
211
231
  entries = Indy.search(source).for(:message => 'Entering Application')
212
- entries.first.keys
213
- # => [:line, :time, :severity, :application, :message]
232
+ entries.first.members
233
+ # => ["time", "severity", "application", "message", "raw_entry"]
214
234
 
215
235
  Indy.search(source).for(:message => 'Entering Application').each do |entry|
216
236
  puts "[#{entry.time}] #{entry.message}: #{entry.application}"
@@ -228,15 +248,17 @@ To create a report in /coverage, run
228
248
  gem install simplecov
229
249
  COVERAGE=true rake test
230
250
 
231
- ## Supported Rubies
251
+ Compatibility
252
+ -------------
232
253
 
233
- This library aims to support and is tested against the follow Ruby implementations:
234
- * Ruby 1.8.7
235
- * Ruby 1.9.2
236
- * Rubinius
254
+ Indy supports MacOS, *nix, and MS Windows and runs on the following ruby flavors:
237
255
 
238
- Testing with RVM:
239
- $ rvm 1.8.7,1.9.2,rbx exec rake test
256
+ - 2.2.1
257
+ - 1.9.3
258
+ - 1.8.7
259
+ - ree
260
+ - jruby-1.7.20
261
+ - rbx-2.2.7
240
262
 
241
263
  LICENSE
242
264
  -------
@@ -2,7 +2,7 @@
2
2
  Feature: Finding log entries in a file
3
3
 
4
4
  Background:
5
- Given the following log file:
5
+ Given the following log file path:
6
6
  """
7
7
  spec/data.log
8
8
  """
@@ -0,0 +1,30 @@
1
+ @application
2
+ Feature: Finding log entries in a file
3
+
4
+ Background:
5
+ Given the following log file object:
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,15 @@
1
+ @time @after
2
+ Feature: Finding log messages using the combined log format
3
+ As an Indy user I am able to find data in a file that uses common log format
4
+
5
+ Background:
6
+ Given the following log, using COMBINED_LOG_FORMAT:
7
+ """
8
+ 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"
9
+ 127.0.0.2 - adam [12/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"
10
+ 127.0.0.3 - larry [13/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"
11
+ """
12
+
13
+ Scenario: Count of entries after a specified time
14
+ When searching the log for all entries after the time 2000-10-11 11:00:01
15
+ Then I expect to have found 2 log entries
@@ -0,0 +1,19 @@
1
+ @time @after
2
+ Feature: Finding log messages using the common log format
3
+ As an Indy user I am able to find data in a file that uses common log format
4
+
5
+ Background:
6
+ Given the following log, using COMMON_LOG_FORMAT:
7
+ """
8
+ 127.0.0.1 - frank [10/Oct/2010:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
9
+ 127.0.0.1 - frank [11/Oct/2010:13:56:36 -0700] "GET /apache_aa.gif HTTP/1.0" 200 2327
10
+ 127.0.0.1 - sue [13/Oct/2010:13:56:37 -0700] "GET /apache_bb.gif HTTP/1.0" 200 2328
11
+ 127.0.0.1 - larry [14/Oct/2010:13:56:38 -0700] "GET /apache_cc.gif HTTP/1.0" 200 2329
12
+ """
13
+ Scenario: Count of entries after a specified time
14
+ When searching the log for all entries after the time 2010-10-12 13:56:36
15
+ Then I expect to have found 2 log entries
16
+
17
+ Scenario: Count of entries before a COMMON formatted time
18
+ When searching the log for all entries before the time 14/Oct/2010 13:56:37 -0700
19
+ Then I expect to have found 3 log entries
@@ -30,6 +30,6 @@ When /^searching the log for the exact match of custom field ([^"]+)\s*"([^"]+)"
30
30
  end
31
31
 
32
32
  Then /^I expect the (first|last|\d+(?:st|nd|rd|th)) entry to be:$/ do |position,expected|
33
- @results[position].raw_entry.should == expected
33
+ expect(@results[position].raw_entry).to eq(expected)
34
34
  end
35
35
 
@@ -1,12 +1,20 @@
1
1
 
2
- Given /^the following log file:$/ do |string|
2
+ Given /^the following log file object:$/ do |string|
3
3
  @indy = Indy.search(File.open(string, 'r'))
4
4
  end
5
5
 
6
+ Given /^the following log file path:$/ do |string|
7
+ @indy = Indy.search(:file => string)
8
+ end
9
+
6
10
  Given /^the following log:$/ do |string|
7
11
  @indy = Indy.search(string)
8
12
  end
9
13
 
14
+ Given /^the following log, using (COMMON_LOG_FORMAT|COMBINED_LOG_FORMAT):$/ do |log_format, string|
15
+ @indy = Indy.search(string).with("Indy::#{log_format}")
16
+ end
17
+
10
18
  And /^the custom pattern \(([^\)]+)\):$/ do |fields,pattern|
11
19
  @indy = @indy.with({ :entry_regexp => pattern, :entry_fields => fields.split(',').map{|f| f.to_sym} })
12
- end
20
+ end
@@ -8,7 +8,7 @@ Transform /^(\d+)$/ do |number|
8
8
  end
9
9
 
10
10
  Then /^I expect to have found (no|\d+) log entr(?:y|ies)$/ do |count|
11
- @results.size.should == count
11
+ expect(@results.size).to eq(count)
12
12
  end
13
13
 
14
14
  Transform /^first$/ do |order|
@@ -12,28 +12,29 @@ Gem::Specification.new do |s|
12
12
  s.license = 'MIT'
13
13
 
14
14
  s.platform = Gem::Platform::RUBY
15
- s.required_ruby_version = '>= 1.8.5'
16
- s.add_dependency('activesupport', '>= 2.3.5')
17
-
18
- s.add_development_dependency('rake')
19
- s.add_development_dependency('i18n')
20
- s.add_development_dependency('cucumber', '>= 1.1.0')
21
- s.add_development_dependency('yard', '>= 0.7.2')
22
- s.add_development_dependency('rspec', '>= 2.9.0')
23
- s.add_development_dependency('rspec-mocks', '>= 2.9.0')
24
- s.add_development_dependency('rb-fsevent')
25
- s.add_development_dependency('ruby_gntp')
26
- s.add_development_dependency('growl')
15
+ s.required_ruby_version = '>= 1.8.7'
16
+ s.add_dependency('activesupport', '~> 3.1.12')
17
+
18
+ s.add_development_dependency('rake', '~> 10.4.0')
19
+ s.add_development_dependency('i18n', '~> 0.6.11')
20
+ s.add_development_dependency('cucumber', '~> 1.3.20')
21
+ s.add_development_dependency('yard', '~> 0.8.7.6')
22
+ s.add_development_dependency('rspec', '~> 3.4.0')
23
+ s.add_development_dependency('rspec-mocks', '~> 3.4.0')
24
+ s.add_development_dependency('rb-fsevent', '~> 0.9.0')
25
+ s.add_development_dependency('ruby_gntp', '~> 0.3.0')
26
+ s.add_development_dependency('growl', '~> 1.0.0')
27
27
 
28
28
  unless ENV['TRAVIS'] == 'true'
29
- s.add_development_dependency('yard-cucumber', '>= 2.1.1')
30
- s.add_development_dependency('flog', '>= 2.5.0')
31
- s.add_development_dependency('guard')
29
+ s.add_development_dependency('yard-cucumber', '~> 2.3.0')
30
+ s.add_development_dependency('flog', '~> 4.3.0')
31
+ s.add_development_dependency('guard', '~> 1.8.0')
32
32
  unless ENV['RUBY_VERSION'] && ENV['RUBY_VERSION'].match(/jruby|rbx/)
33
- s.add_development_dependency('guard-rspec')
34
- s.add_development_dependency('guard-cucumber')
35
- s.add_development_dependency('rspec-prof', '>= 0.0.3')
36
- s.add_development_dependency('simplecov', '>= 0.4.0')
33
+ s.add_development_dependency('guard-rspec', '~> 1.2.0')
34
+ s.add_development_dependency('guard-cucumber', '~> 1.5.0')
35
+ s.add_development_dependency('ruby-prof', '~> 0.13.0')
36
+ s.add_development_dependency('rspec-prof', '~> 0.0.0')
37
+ s.add_development_dependency('simplecov', '~> 0.11.0')
37
38
  end
38
39
  end
39
40
 
@@ -52,8 +53,6 @@ Gem::Specification.new do |s|
52
53
 
53
54
  }
54
55
 
55
- # s.rubygems_version = "1.6.1"
56
-
57
56
  exclusions = [File.join("performance", "large.log")]
58
57
  s.files = `git ls-files`.split("\n") - exclusions
59
58
  s.test_files = `git ls-files -- {spec,features,performance}/*`.split("\n")
@@ -14,13 +14,12 @@ class Indy
14
14
  # Indy.new(:time_format => '%m-%d-%Y', :entry_regexp => LOG_REGEX_PATTERN, :entry_fields => [:time,:application,:message], :source => LOG_FILE)
15
15
  #
16
16
  def initialize(args)
17
- params_hash = args.dup
18
- raise ArgumentError, "Source parameter not specified" unless (params_hash.respond_to?(:keys) && params_hash.keys.include?(:source))
19
- source_param = params_hash[:source]
20
- params_hash.delete :source
21
- log_definition = LogDefinition.new(params_hash)
22
- @search = Search.new(:log_definition => log_definition)
23
- @search.source = Source.new(source_param,log_definition)
17
+ params = args.dup
18
+ raise ArgumentError, "Source parameter not specified" unless (params.respond_to?(:keys) && params.keys.include?(:source))
19
+ source_param = params[:source]
20
+ params.delete :source
21
+ @search = Search.new()
22
+ @search.source = Source.new( source_param, LogDefinition.new(params) )
24
23
  end
25
24
 
26
25
  class << self
@@ -68,7 +67,10 @@ class Indy
68
67
  # Indy.search(LOG_FILE).with(/^(\d{2}.\d{2}.\d{2})\s*(.+)$/,:time,:message)
69
68
  #
70
69
  def with(params=:default)
71
- @search.log_definition = LogDefinition.new(params)
70
+ if params.kind_of?(String) && params.match(/^Indy::/)
71
+ params = params.constantize
72
+ end
73
+ @search.source.log_definition = LogDefinition.new(params)
72
74
  self
73
75
  end
74
76
 
@@ -119,8 +121,8 @@ class Indy
119
121
  raise ArgumentError, "Unsupported parameter to last(): #{scope_criteria.inspect}" unless scope_criteria.respond_to?(:keys) and scope_criteria[:span]
120
122
  span = (scope_criteria[:span].to_i * 60).seconds
121
123
  entry = last_entries(1)[0]
122
- start_time = Indy::Time.parse_date(entry[:time],@search.log_definition.time_format) - span
123
- within(:start_time => start_time, :end_time => Indy::Time.forever(@search.log_definition.time_format))
124
+ start_time = Indy::Time.parse_date(entry[:time], @search.source.log_definition.time_format) - span
125
+ within(:start_time => start_time, :end_time => Indy::Time.forever(@search.source.log_definition.time_format))
124
126
  self
125
127
  end
126
128
 
@@ -165,7 +167,7 @@ class Indy
165
167
  #
166
168
  def around(scope_criteria)
167
169
  raise ArgumentError unless scope_criteria.respond_to?(:keys) and scope_criteria[:time]
168
- time = Indy::Time.parse_date(scope_criteria[:time])
170
+ time = Indy::Time.parse_date(scope_criteria[:time], @search.source.log_definition.time_format)
169
171
  mid_span = ((scope_criteria[:span].to_i * 60)/2).seconds rescue 300.seconds
170
172
  within(:start_time => time - mid_span, :end_time => time + mid_span, :inclusive => nil)
171
173
  self
@@ -207,14 +209,14 @@ class Indy
207
209
  result = []
208
210
  source_io = @search.source.open
209
211
  source_io.reverse_each do |entry|
210
- hash = @search.log_definition.parse_entry(entry)
212
+ hash = @search.source.log_definition.parse_entry(entry)
211
213
  if hash
212
214
  num_entries += 1
213
215
  result << hash
214
216
  break if num_entries >= num
215
217
  end
216
218
  end
217
- result.collect{|entry| @search.log_definition.create_struct(entry)}
219
+ result.collect{|entry| @search.source.log_definition.create_struct(entry)}
218
220
  end
219
221
 
220
222
  end