sawmill 0.0.2 → 0.0.3

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.
Files changed (33) hide show
  1. data/History.rdoc +17 -0
  2. data/lib/sawmill/entry.rb +17 -1
  3. data/lib/sawmill/entry_processor/build_records.rb +10 -7
  4. data/lib/sawmill/entry_processor/compile_report.rb +115 -0
  5. data/lib/sawmill/entry_processor/conditionals.rb +22 -23
  6. data/lib/sawmill/entry_processor/count_entries.rb +112 -0
  7. data/lib/sawmill/entry_processor/{filter_basic_fields.rb → filter_by_basic_fields.rb} +3 -3
  8. data/lib/sawmill/entry_processor/filter_by_block.rb +96 -0
  9. data/lib/sawmill/entry_processor/format.rb +9 -1
  10. data/lib/sawmill/entry_processor/simple_queue.rb +2 -1
  11. data/lib/sawmill/entry_processor.rb +68 -5
  12. data/lib/sawmill/errors.rb +7 -0
  13. data/lib/sawmill/interface.rb +324 -0
  14. data/lib/sawmill/logger.rb +8 -7
  15. data/lib/sawmill/record.rb +14 -0
  16. data/lib/sawmill/record_processor/compile_report.rb +113 -0
  17. data/lib/sawmill/record_processor/conditionals.rb +12 -13
  18. data/lib/sawmill/record_processor/count_records.rb +84 -0
  19. data/lib/sawmill/record_processor/decompose.rb +2 -2
  20. data/lib/sawmill/record_processor/filter_by_attributes.rb +2 -1
  21. data/lib/sawmill/record_processor/filter_by_block.rb +95 -0
  22. data/lib/sawmill/record_processor/filter_by_record_id.rb +2 -1
  23. data/lib/sawmill/record_processor/format.rb +8 -2
  24. data/lib/sawmill/record_processor/simple_queue.rb +2 -1
  25. data/lib/sawmill/record_processor.rb +69 -5
  26. data/lib/sawmill/rotater/date_based_log_file.rb +8 -8
  27. data/lib/sawmill/rotater/shifting_log_file.rb +7 -6
  28. data/lib/sawmill/util/processor_tools.rb +71 -0
  29. data/lib/sawmill/version.rb +1 -3
  30. data/lib/sawmill.rb +9 -1
  31. data/tests/tc_entry_processors.rb +7 -7
  32. data/tests/tc_reports.rb +101 -0
  33. metadata +13 -3
@@ -84,9 +84,8 @@ module Sawmill
84
84
  end
85
85
  end
86
86
 
87
- def close
88
- @on_true.close
89
- @on_false.close if @on_false
87
+ def finish
88
+ Util::ProcessorTools.collect_finish_values([@on_true, @on_false])
90
89
  end
91
90
 
92
91
 
@@ -122,8 +121,8 @@ module Sawmill
122
121
  !@child.extra_entry(record_)
123
122
  end
124
123
 
125
- def close
126
- @child.close
124
+ def finish
125
+ @child.finish
127
126
  end
128
127
 
129
128
 
@@ -170,8 +169,8 @@ module Sawmill
170
169
  true
171
170
  end
172
171
 
173
- def close
174
- @children.each{ |child_| child_.close }
172
+ def finish
173
+ Util::ProcessorTools.collect_finish_values(@children)
175
174
  end
176
175
 
177
176
 
@@ -218,8 +217,8 @@ module Sawmill
218
217
  false
219
218
  end
220
219
 
221
- def close
222
- @children.each{ |child_| child_.close }
220
+ def finish
221
+ Util::ProcessorTools.collect_finish_values(@children)
223
222
  end
224
223
 
225
224
 
@@ -271,8 +270,8 @@ module Sawmill
271
270
  end
272
271
  end
273
272
 
274
- def close
275
- @children.each{ |child_| child_.close }
273
+ def finish
274
+ Util::ProcessorTools.collect_finish_values(@children)
276
275
  end
277
276
 
278
277
 
@@ -317,8 +316,8 @@ module Sawmill
317
316
  end
318
317
  end
319
318
 
320
- def close
321
- @children.each{ |child_| child_.close }
319
+ def finish
320
+ Util::ProcessorTools.collect_finish_values(@children)
322
321
  end
323
322
 
324
323
 
@@ -0,0 +1,84 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Sawmill entry processor that generates reports
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2009 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Sawmill
38
+
39
+ module RecordProcessor
40
+
41
+
42
+ # This processor reports the number of records processed.
43
+
44
+ class CountRecords < Base
45
+
46
+
47
+ # Create a count-records report.
48
+ #
49
+ # Recognized options include:
50
+ #
51
+ # <tt>:label</tt>::
52
+ # Label to use for the report.
53
+ # If provided, the report is returned as a string of the form
54
+ # "#{label}#{value}"
55
+ # If set to nil or absent, the report is returned as an integer.
56
+
57
+ def initialize(opts_={})
58
+ @label = opts_[:label]
59
+ @finished = false
60
+ @count = 0
61
+ end
62
+
63
+
64
+ def record(record_)
65
+ @count += 1 unless @finished
66
+ true
67
+ end
68
+
69
+ def extra_entry(entry_)
70
+ true
71
+ end
72
+
73
+ def finish
74
+ @finished = true
75
+ @label ? "#{@label}#{@count}" : @count
76
+ end
77
+
78
+
79
+ end
80
+
81
+
82
+ end
83
+
84
+ end
@@ -63,8 +63,8 @@ module Sawmill
63
63
  true
64
64
  end
65
65
 
66
- def close
67
- @processor.close
66
+ def finish
67
+ @processor.finish
68
68
  end
69
69
 
70
70
  end
@@ -76,7 +76,8 @@ module Sawmill
76
76
  false
77
77
  end
78
78
 
79
- def close
79
+ def finish
80
+ nil
80
81
  end
81
82
 
82
83
  end
@@ -0,0 +1,95 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Sawmill record processor that calls a block
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2009 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Sawmill
38
+
39
+ module RecordProcessor
40
+
41
+
42
+ # A record filter that calls a block to perform its check.
43
+ #
44
+ # This is a boolean processor, so it merely returns true or false based
45
+ # on the filter result. Use this in conjunction with an If processor to
46
+ # actually perform other actions based on the result.
47
+
48
+ class FilterByBlock < Base
49
+
50
+
51
+ # Create a new filter. Provide the block, which should take a
52
+ # Sawmill::Record as the parameter and return a boolean.
53
+ #
54
+ # By default, extra entries always return false. Provide an
55
+ # extra entry filter to change this behavior.
56
+
57
+ def initialize(&block_)
58
+ to_filter_record(&block_)
59
+ end
60
+
61
+
62
+ # Provide a block to filter records. It should take a Sawmill::Record
63
+ # as the parameter, and return a boolean.
64
+
65
+ def to_filter_record(&block_)
66
+ @block = block_ || Proc.new{ |record_| false }
67
+ end
68
+
69
+
70
+ # Provide a block to filter extra entries. It should take an entry
71
+ # object as the parameter, and return a boolean.
72
+
73
+ def to_filter_extra_entry(&block_)
74
+ @extra_entry_block = block_ || Proc.new{ |entry_| false }
75
+ end
76
+
77
+
78
+ def record(record_)
79
+ @block.call(record_)
80
+ end
81
+
82
+ def extra_entry(entry_)
83
+ @extra_entry_block.call(entry_)
84
+ end
85
+
86
+ def finish
87
+ nil
88
+ end
89
+
90
+ end
91
+
92
+
93
+ end
94
+
95
+ end
@@ -66,7 +66,8 @@ module Sawmill
66
66
  @record_id === id_
67
67
  end
68
68
 
69
- def close
69
+ def finish
70
+ nil
70
71
  end
71
72
 
72
73
  end
@@ -59,8 +59,14 @@ module Sawmill
59
59
  # Default is 2. Accepted values are 0 to 6.
60
60
  # <tt>:level_width</tt>::
61
61
  # Column width of the level field.
62
+ # <tt>:entry_length_limit</tt>::
63
+ # Limit to the entry length. Entries are truncated to this length
64
+ # when written. If not specified, entries are not truncated.
62
65
 
63
66
  def initialize(destination_, opts_={})
67
+ if (entry_length_limit_ = opts_.delete(:entry_length_limit))
68
+ opts_ = opts_.merge(:length_limit => entry_length_limit_)
69
+ end
64
70
  @formatter = EntryProcessor::Format.new(destination_, opts_)
65
71
  @classifier = EntryClassifier.new(@formatter)
66
72
  end
@@ -76,8 +82,8 @@ module Sawmill
76
82
  true
77
83
  end
78
84
 
79
- def close
80
- @formatter.close
85
+ def finish
86
+ @formatter.finish
81
87
  end
82
88
 
83
89
  end
@@ -117,8 +117,9 @@ module Sawmill
117
117
  @extra_entries_queue.enqueue(entry_) unless @closed
118
118
  end
119
119
 
120
- def close
120
+ def finish
121
121
  @closed = true
122
+ nil
122
123
  end
123
124
 
124
125
 
@@ -82,15 +82,35 @@ module Sawmill
82
82
  end
83
83
 
84
84
 
85
- # Close down the processor. After this is called, the processor should
86
- # ignore any further records.
87
-
88
- def close
85
+ # Close down the processor, perform any finishing tasks, and return
86
+ # any final calculated value.
87
+ #
88
+ # After this is called, the processor should ignore any further entries.
89
+ #
90
+ # The return value can be used to communicate a final computed value,
91
+ # analysis report, or other data back to the caller. It may also be
92
+ # nil, signalling no finish value.
93
+ #
94
+ # Note that some processors function to multiplex other processors. In
95
+ # such a case, their finish value needs to be an aggregate of the
96
+ # values returned by their descendants. To handle these cases, we
97
+ # define a protocol for finish values. A finish value may be nil, an
98
+ # Array, or another kind of object. Nil means "no value" and thus can
99
+ # be ignored by a processor that aggregates other values. An Array
100
+ # indicates an aggregation; if finish returns an array, it is _always_
101
+ # an aggregation of actual values. Any other kind of object is to be
102
+ # interpreted as a single value. This means that if you want to
103
+ # actually return an array _as_ a value, you must wrap it in another
104
+ # array, indicating "an array of one finish value, and that finish
105
+ # value also happens to be an array itself".
106
+
107
+ def finish
108
+ nil
89
109
  end
90
110
 
91
111
 
92
112
  def self.inherited(subclass_) # :nodoc:
93
- if subclass_.name =~ /^Sawmill::RecordProcessor::(.*)$/
113
+ if subclass_.name =~ /^Sawmill::RecordProcessor::([^:]+)$/
94
114
  name_ = $1
95
115
  Builder.class_eval do
96
116
  define_method(name_) do |*args_|
@@ -101,6 +121,37 @@ module Sawmill
101
121
  end
102
122
 
103
123
 
124
+ # Add a method to the processor building DSL. You may call this method
125
+ # in the DSL to create an instance of this record processor.
126
+ # You must pass a method name that begins with a lower-case letter or
127
+ # underscore.
128
+ #
129
+ # Processors that subclass Sawmill::RecordProcessor::Base and live in
130
+ # the Sawmill::RecordProcessor namespace will have their class name
131
+ # automatically added to the DSL. This method is primarily for other
132
+ # processors that do not live in that module namespace.
133
+ #
134
+ # See Sawmill::RecordProcessor#build for more information.
135
+ #
136
+ # Raises Sawmill::Errors::DSLMethodError if the given name is already
137
+ # taken.
138
+
139
+ def self.add_dsl_method(name_)
140
+ klass_ = self
141
+ if name_.to_s !~ /^[a-z_]/
142
+ raise ::ArgumentError, "Method name must begin with a lower-case letter or underscore"
143
+ end
144
+ if Builder.method_defined?(name_)
145
+ raise Errors::DSLMethodError, "Method #{name_} already defined"
146
+ end
147
+ Builder.class_eval do
148
+ define_method(name_) do |*args_|
149
+ klass_.new(*args_)
150
+ end
151
+ end
152
+ end
153
+
154
+
104
155
  private
105
156
 
106
157
  def _interpret_processor_array(param_) # :nodoc:
@@ -125,6 +176,19 @@ module Sawmill
125
176
  # A convenience DSL for building sets of processors. This is typically
126
177
  # useful for constructing if-expressions using the boolean operation
127
178
  # processors.
179
+ #
180
+ # Every record processor that lives in the Sawmill::RecordProcessor
181
+ # module and subclasses Sawmill::RecordProcessor::Base can be
182
+ # instantiated by using its name as a function call. Other processors
183
+ # may also add themselves to the DSL by calling
184
+ # Sawmill::RecordProcessor::Base#add_dsl_method.
185
+ #
186
+ # For example:
187
+ #
188
+ # Sawmill::RecordProcessor.build do
189
+ # If(Or(FilterByRecordId('12345678'), FilterByRecordId('abcdefg')),
190
+ # Format(STDOUT))
191
+ # end
128
192
 
129
193
  def self.build(&block_)
130
194
  ::Blockenspiel.invoke(block_, Builder.new)
@@ -65,27 +65,27 @@ module Sawmill
65
65
  # How often the log files should turn over. Allowed values are:
66
66
  # <tt>:yearly</tt>, <tt>:monthly</tt>, <tt>:daily</tt>,
67
67
  # <tt>:hourly</tt>, and <tt>:never</tt>.
68
- # <tt>:dirname</tt>::
69
- # The directory for the logfiles to be output.
68
+ # <tt>:basedir</tt>::
69
+ # The base directory used if the filepath is a relative path.
70
70
  # If not specified, the current working directory is used.
71
71
  # <tt>:prefix</tt>::
72
- # The logfile name prefix.
72
+ # The logfile path prefix.
73
73
  # In the filename "rails.2009-10-11.log", the prefix is "rails".
74
74
  # If not specified, defaults to "sawmill".
75
75
  # <tt>:suffix</tt>::
76
76
  # The logfile name prefix.
77
77
  # In the filename "rails.2009-10-11.log", the suffix is ".log".
78
78
  # If not specified, defaults to ".log".
79
- # <tt>:local_timezone</tt>::
79
+ # <tt>:local_datestamps</tt>::
80
80
  # If true, use the local timezone to create datestamps.
81
81
  # The default is to use UTC.
82
82
 
83
83
  def initialize(options_)
84
84
  @turnover_frequency = options_[:turnover_frequency] || :none
85
- dirname_ = options_[:dirname] || ::Dir.getwd
86
- @prefix = ::File.join(dirname_, options_[:prefix] || 'sawmill')
85
+ @prefix = ::File.expand_path(options_[:prefix] || 'sawmill',
86
+ options_[:basedir] || options_[:dirname] || ::Dir.getwd)
87
87
  @suffix = options_[:suffix] || '.log'
88
- @local_timezone = options_[:local_timezone]
88
+ @local_datestamps = options_[:local_datestamps]
89
89
  @date_pattern =
90
90
  case @turnover_frequency
91
91
  when :yearly then "%Y"
@@ -102,7 +102,7 @@ module Sawmill
102
102
  def preferred_handle
103
103
  if @date_pattern
104
104
  time_ = ::Time.now
105
- time_.utc unless @local_timezone
105
+ time_.utc unless @local_datestamps
106
106
  time_.strftime(@date_pattern)
107
107
  else
108
108
  ''
@@ -56,11 +56,12 @@ module Sawmill
56
56
  #
57
57
  # Recognized options include:
58
58
  #
59
- # <tt>:dirname</tt>::
60
- # The directory for the logfiles to be output.
59
+ # <tt>:basedir</tt>::
60
+ # The base directory used if the filepath is a relative path.
61
61
  # If not specified, the current working directory is used.
62
- # <tt>:filename</tt>::
63
- # The logfile name.
62
+ # <tt>:filepath</tt>::
63
+ # The path to the log file. This may be an absolute path or a
64
+ # path relative to basedir.
64
65
  # If not specified, defaults to "sawmill.log".
65
66
  # <tt>:max_logfile_size</tt>::
66
67
  # A logfile will try to rotate once it has reached this size in
@@ -91,8 +92,8 @@ module Sawmill
91
92
  end
92
93
  @history_size = options_[:history_size].to_i
93
94
  @history_size = 1 if @history_size < 1 && (@max_logfile_size || @shift_period)
94
- dirname_ = options_[:dirname] || ::Dir.getwd
95
- @normal_path = ::File.join(dirname_, options_[:filename] || 'sawmill.log')
95
+ @normal_path = ::File.expand_path(options_[:filepath] || 'sawmill.log',
96
+ options_[:basedir] || ::Dir.getwd)
96
97
  @preferred_handle = 0
97
98
  @open_handles = {}
98
99
  @last_shift = ::Time.now
@@ -0,0 +1,71 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Sawmill tools for building processors
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2009 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module Sawmill
38
+
39
+ module Util
40
+
41
+
42
+ # Some miscellaneous tools for building processors
43
+
44
+ module ProcessorTools
45
+
46
+
47
+ def self.collect_finish_values(children_)
48
+ ret_ = nil
49
+ children_.each do |child_|
50
+ unless child_.nil?
51
+ val_ = child_.finish
52
+ unless val_.nil?
53
+ ret_ ||= []
54
+ if val_.kind_of?(::Array)
55
+ ret_.concat(val_)
56
+ else
57
+ ret_.push(val_)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ ret_
63
+ end
64
+
65
+
66
+ end
67
+
68
+
69
+ end
70
+
71
+ end
@@ -34,12 +34,10 @@
34
34
  ;
35
35
 
36
36
 
37
- # This module is a namespace for Sawmill.
38
-
39
37
  module Sawmill
40
38
 
41
39
  # Current gem version, as a frozen string.
42
- VERSION_STRING = '0.0.2'.freeze
40
+ VERSION_STRING = '0.0.3'.freeze
43
41
 
44
42
  # Current gem version, as a Versionomy::Value.
45
43
  VERSION = ::Versionomy.parse(VERSION_STRING, :standard)
data/lib/sawmill.rb CHANGED
@@ -50,6 +50,7 @@ includes_ = [
50
50
  'version',
51
51
  'util/queue',
52
52
  'util/heap',
53
+ 'util/processor_tools',
53
54
  'errors',
54
55
  'level',
55
56
  'entry',
@@ -57,17 +58,23 @@ includes_ = [
57
58
  'entry_processor',
58
59
  'entry_processor/conditionals',
59
60
  'entry_processor/simple_queue',
60
- 'entry_processor/filter_basic_fields',
61
+ 'entry_processor/filter_by_basic_fields',
62
+ 'entry_processor/filter_by_block',
61
63
  'entry_processor/build_records',
62
64
  'entry_processor/format',
65
+ 'entry_processor/count_entries',
66
+ 'entry_processor/compile_report',
63
67
  'record',
64
68
  'record_processor',
65
69
  'record_processor/conditionals',
66
70
  'record_processor/filter_by_record_id',
67
71
  'record_processor/filter_by_attributes',
72
+ 'record_processor/filter_by_block',
68
73
  'record_processor/simple_queue',
69
74
  'record_processor/decompose',
70
75
  'record_processor/format',
76
+ 'record_processor/count_records',
77
+ 'record_processor/compile_report',
71
78
  'parser',
72
79
  'multi_parser',
73
80
  'logger',
@@ -76,5 +83,6 @@ includes_ = [
76
83
  'rotater/date_based_log_file',
77
84
  'rotater/shifting_log_file',
78
85
  'log_record_middleware',
86
+ 'interface',
79
87
  ]
80
88
  includes_.each{ |file_| require "#{dir_}/#{file_}" }
@@ -53,7 +53,7 @@ module Sawmill
53
53
 
54
54
  def test_basic_level_filter
55
55
  processor_ = ::Sawmill::EntryProcessor::build do
56
- If(FilterBasicFields(:level => :WARN), @entries)
56
+ If(FilterByBasicFields(:level => :WARN), @entries)
57
57
  end
58
58
  @logger = ::Sawmill::Logger.new(:processor => processor_)
59
59
  @logger.warn('Hello 1')
@@ -69,7 +69,7 @@ module Sawmill
69
69
 
70
70
  def test_basic_progname_filter
71
71
  processor_ = ::Sawmill::EntryProcessor::build do
72
- If(FilterBasicFields(:progname => 'rails'), @entries)
72
+ If(FilterByBasicFields(:progname => 'rails'), @entries)
73
73
  end
74
74
  @logger = ::Sawmill::Logger.new(:processor => processor_)
75
75
  @logger.info('Hello 1')
@@ -84,8 +84,8 @@ module Sawmill
84
84
 
85
85
  def test_conjunction_and
86
86
  processor_ = ::Sawmill::EntryProcessor::build do
87
- If(And(FilterBasicFields(:progname => 'rails'),
88
- FilterBasicFields(:level => :WARN)), @entries)
87
+ If(And(FilterByBasicFields(:progname => 'rails'),
88
+ FilterByBasicFields(:level => :WARN)), @entries)
89
89
  end
90
90
  @logger = ::Sawmill::Logger.new(:processor => processor_)
91
91
  @logger.warn('Hello 1')
@@ -101,8 +101,8 @@ module Sawmill
101
101
 
102
102
  def test_conjunction_or
103
103
  processor_ = ::Sawmill::EntryProcessor::build do
104
- If(Or(FilterBasicFields(:progname => 'rails'),
105
- FilterBasicFields(:level => :WARN)), @entries)
104
+ If(Or(FilterByBasicFields(:progname => 'rails'),
105
+ FilterByBasicFields(:level => :WARN)), @entries)
106
106
  end
107
107
  @logger = ::Sawmill::Logger.new(:processor => processor_)
108
108
  @logger.warn('Hello 1')
@@ -120,7 +120,7 @@ module Sawmill
120
120
 
121
121
  def test_boolean_not
122
122
  processor_ = ::Sawmill::EntryProcessor::build do
123
- If(Not(FilterBasicFields(:progname => 'rails')), @entries)
123
+ If(Not(FilterByBasicFields(:progname => 'rails')), @entries)
124
124
  end
125
125
  @logger = ::Sawmill::Logger.new(:processor => processor_)
126
126
  @logger.info('Hello 1')