sawmill 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +7 -0
- data/Version +1 -1
- data/lib/sawmill.rb +6 -6
- data/lib/sawmill/entry.rb +108 -108
- data/lib/sawmill/entry_classifier.rb +19 -19
- data/lib/sawmill/entry_processor.rb +63 -63
- data/lib/sawmill/entry_processor/build_records.rb +39 -39
- data/lib/sawmill/entry_processor/compile_report.rb +32 -32
- data/lib/sawmill/entry_processor/conditionals.rb +110 -110
- data/lib/sawmill/entry_processor/count_entries.rb +27 -27
- data/lib/sawmill/entry_processor/filter_by_basic_fields.rb +32 -32
- data/lib/sawmill/entry_processor/filter_by_block.rb +28 -28
- data/lib/sawmill/entry_processor/format.rb +41 -36
- data/lib/sawmill/entry_processor/interpret_stats.rb +24 -24
- data/lib/sawmill/entry_processor/simple_queue.rb +38 -38
- data/lib/sawmill/errors.rb +28 -28
- data/lib/sawmill/interface.rb +51 -51
- data/lib/sawmill/level.rb +75 -75
- data/lib/sawmill/log_record_middleware.rb +21 -21
- data/lib/sawmill/logger.rb +94 -94
- data/lib/sawmill/multi_parser.rb +28 -28
- data/lib/sawmill/parser.rb +32 -32
- data/lib/sawmill/railtie.rb +31 -31
- data/lib/sawmill/record.rb +74 -74
- data/lib/sawmill/record_processor.rb +54 -54
- data/lib/sawmill/record_processor/compile_report.rb +32 -32
- data/lib/sawmill/record_processor/conditionals.rb +92 -92
- data/lib/sawmill/record_processor/count_records.rb +24 -24
- data/lib/sawmill/record_processor/decompose.rb +21 -21
- data/lib/sawmill/record_processor/filter_by_attributes.rb +22 -22
- data/lib/sawmill/record_processor/filter_by_block.rb +29 -29
- data/lib/sawmill/record_processor/filter_by_record_id.rb +22 -22
- data/lib/sawmill/record_processor/format.rb +24 -24
- data/lib/sawmill/record_processor/simple_queue.rb +44 -44
- data/lib/sawmill/rotater.rb +60 -60
- data/lib/sawmill/rotater/base.rb +28 -28
- data/lib/sawmill/rotater/date_based_log_file.rb +50 -50
- data/lib/sawmill/rotater/shifting_log_file.rb +34 -34
- data/lib/sawmill/stats_middleware.rb +21 -21
- data/lib/sawmill/stats_railtie.rb +33 -33
- data/lib/sawmill/util/heap.rb +41 -41
- data/lib/sawmill/util/processor_tools.rb +17 -17
- data/lib/sawmill/util/queue.rb +33 -33
- data/lib/sawmill/version.rb +9 -9
- data/test/tc_entry_processors.rb +27 -27
- data/test/tc_formatter_parser.rb +40 -40
- data/test/tc_levels.rb +27 -27
- data/test/tc_logger.rb +49 -49
- data/test/tc_multi_parser.rb +18 -18
- data/test/tc_record_processors.rb +21 -21
- data/test/tc_records.rb +39 -39
- data/test/tc_reports.rb +19 -19
- metadata +10 -5
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill entry processor that generates reports
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
# Copyright 2009 Daniel Azuma
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,21 +35,21 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module Sawmill
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
|
40
40
|
module EntryProcessor
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
|
43
43
|
# This processor collects and formats reports from descendant
|
44
44
|
# entry processors.
|
45
|
-
|
45
|
+
|
46
46
|
class CompileReport < All
|
47
|
-
|
48
|
-
|
47
|
+
|
48
|
+
|
49
49
|
# Create a report collection.
|
50
|
-
#
|
50
|
+
#
|
51
51
|
# Recognized options include:
|
52
|
-
#
|
52
|
+
#
|
53
53
|
# [<tt>:postprocessor</tt>]
|
54
54
|
# Postprocessor proc for individual reports.
|
55
55
|
# See to_postprocess_value.
|
@@ -62,7 +62,7 @@ module Sawmill
|
|
62
62
|
# [<tt>:footer</tt>]
|
63
63
|
# Footer string for the final compiled report.
|
64
64
|
# Default is the empty string.
|
65
|
-
|
65
|
+
|
66
66
|
def initialize(*children_)
|
67
67
|
opts_ = children_.last.kind_of?(::Hash) ? children_.pop : {}
|
68
68
|
@postprocessor = opts_[:postprocessor]
|
@@ -71,32 +71,32 @@ module Sawmill
|
|
71
71
|
@footer = opts_[:footer] || ''
|
72
72
|
super(*children_)
|
73
73
|
end
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
|
76
76
|
# Separator string to be inserted between individual reports.
|
77
77
|
attr_accessor :separator
|
78
|
-
|
78
|
+
|
79
79
|
# Header string for the final compiled report.
|
80
80
|
attr_accessor :header
|
81
|
-
|
81
|
+
|
82
82
|
# Footer string for the final compiled report.
|
83
83
|
attr_accessor :footer
|
84
|
-
|
85
|
-
|
84
|
+
|
85
|
+
|
86
86
|
# Provide a postprocessor block for individual report values.
|
87
87
|
# This block should take a single parameter and return a string
|
88
88
|
# that should be included in the compiled report. It may also
|
89
89
|
# return nil to indicate that the data should not be included.
|
90
|
-
|
90
|
+
|
91
91
|
def to_postprocess_value(&block_)
|
92
92
|
@postprocessor = block_
|
93
93
|
end
|
94
|
-
|
95
|
-
|
94
|
+
|
95
|
+
|
96
96
|
# On finish, this processor calls finish on its descendants, converts
|
97
97
|
# their values into strings and compiles them into a report. It then
|
98
98
|
# returns that report as a string.
|
99
|
-
|
99
|
+
|
100
100
|
def finish
|
101
101
|
values_ = super || []
|
102
102
|
values_ = [values_] unless values_.kind_of?(::Array)
|
@@ -104,12 +104,12 @@ module Sawmill
|
|
104
104
|
values_.compact!
|
105
105
|
"#{@header}#{values_.join(@separator)}#{@footer}"
|
106
106
|
end
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
|
109
109
|
end
|
110
|
-
|
111
|
-
|
110
|
+
|
111
|
+
|
112
112
|
end
|
113
|
-
|
114
|
-
|
113
|
+
|
114
|
+
|
115
115
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill basic entry processors that implement conditionals
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
# Copyright 2009 Daniel Azuma
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,39 +35,39 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module Sawmill
|
38
|
-
|
38
|
+
|
39
39
|
module EntryProcessor
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
# An "if" conditional.
|
43
|
-
#
|
43
|
+
#
|
44
44
|
# Takes a boolean condition processor and executes a processor on true
|
45
45
|
# (and optionally another one on false).
|
46
|
-
#
|
46
|
+
#
|
47
47
|
# For example, this builds a processor that sends formatted log entries
|
48
48
|
# to STDOUT only if their level is at least INFO:
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# processor = Sawmill::EntryProcessor.build do
|
51
51
|
# If(FilterByBasicFields(:level => :INFO), Format(STDOUT))
|
52
52
|
# end
|
53
|
-
|
53
|
+
|
54
54
|
class If < Base
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
|
57
57
|
# Create an "if" conditional.
|
58
|
-
#
|
58
|
+
#
|
59
59
|
# The first parameter must be a processor whose methods return a
|
60
60
|
# boolean value indicating whether the entry should be accepted.
|
61
61
|
# The second parameter is a processor to run on accepted entries.
|
62
62
|
# The optional third parameter is an "else" processor to run on
|
63
63
|
# rejected entries.
|
64
|
-
|
64
|
+
|
65
65
|
def initialize(condition_, on_true_, on_false_=nil)
|
66
66
|
@condition = condition_
|
67
67
|
@on_true = on_true_
|
68
68
|
@on_false = on_false_
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def begin_record(entry_)
|
72
72
|
if @condition.begin_record(entry_)
|
73
73
|
@on_true.begin_record(entry_)
|
@@ -75,7 +75,7 @@ module Sawmill
|
|
75
75
|
@on_false.begin_record(entry_)
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def end_record(entry_)
|
80
80
|
if @condition.end_record(entry_)
|
81
81
|
@on_true.end_record(entry_)
|
@@ -83,7 +83,7 @@ module Sawmill
|
|
83
83
|
@on_false.end_record(entry_)
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def message(entry_)
|
88
88
|
if @condition.message(entry_)
|
89
89
|
@on_true.message(entry_)
|
@@ -91,7 +91,7 @@ module Sawmill
|
|
91
91
|
@on_false.message(entry_)
|
92
92
|
end
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def attribute(entry_)
|
96
96
|
if @condition.attribute(entry_)
|
97
97
|
@on_true.attribute(entry_)
|
@@ -99,7 +99,7 @@ module Sawmill
|
|
99
99
|
@on_false.attribute(entry_)
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def unknown_data(entry_)
|
104
104
|
if @condition.unknown_data(entry_)
|
105
105
|
@on_true.unknown_data(entry_)
|
@@ -107,337 +107,337 @@ module Sawmill
|
|
107
107
|
@on_false.unknown_data(entry_)
|
108
108
|
end
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
def finish
|
112
112
|
Util::ProcessorTools.collect_finish_values([@on_true, @on_false])
|
113
113
|
end
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
|
116
116
|
end
|
117
|
-
|
118
|
-
|
117
|
+
|
118
|
+
|
119
119
|
# A boolean processor that returns the boolean negation of a given
|
120
120
|
# processor.
|
121
|
-
#
|
121
|
+
#
|
122
122
|
# For example, this builds a processor that sends formatted log entries
|
123
123
|
# to STDOUT only if their level is NOT at least INFO:
|
124
|
-
#
|
124
|
+
#
|
125
125
|
# processor = Sawmill::EntryProcessor.build do
|
126
126
|
# If(Not(FilterByBasicFields(:level => :INFO)), Format(STDOUT))
|
127
127
|
# end
|
128
|
-
|
128
|
+
|
129
129
|
class Not < Base
|
130
|
-
|
131
|
-
|
130
|
+
|
131
|
+
|
132
132
|
# Create a "not" boolean.
|
133
133
|
# The parameter is a boolean processor to run. This processor returns
|
134
134
|
# the boolean negation of its output.
|
135
|
-
|
135
|
+
|
136
136
|
def initialize(child_)
|
137
137
|
@child = _interpret_processor(child_)
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
def begin_record(entry_)
|
141
141
|
!@child.begin_record(entry_)
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def end_record(entry_)
|
145
145
|
!@child.end_record(entry_)
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
def message(entry_)
|
149
149
|
!@child.message(entry_)
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def attribute(entry_)
|
153
153
|
!@child.attribute(entry_)
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
def unknown_data(entry_)
|
157
157
|
!@child.unknown_data(entry_)
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
def finish
|
161
161
|
@child.finish
|
162
162
|
end
|
163
|
-
|
164
|
-
|
163
|
+
|
164
|
+
|
165
165
|
end
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
|
168
168
|
# A boolean processor that returns true if and only if all its child
|
169
169
|
# processors return true. This version short-circuits the processing,
|
170
170
|
# so once one child returns false, subsequent children are not called
|
171
171
|
# at all.
|
172
|
-
#
|
172
|
+
#
|
173
173
|
# For example, this builds a processor that sends formatted log entries
|
174
174
|
# to STDOUT only if their level is at least INFO AND the progname is
|
175
175
|
# is "rails":
|
176
|
-
#
|
176
|
+
#
|
177
177
|
# processor = Sawmill::EntryProcessor.build do
|
178
178
|
# If(And(FilterByBasicFields(:level => :INFO),
|
179
179
|
# FilterByBasicFields(:progname => 'rails')),
|
180
180
|
# Format(STDOUT))
|
181
181
|
# end
|
182
|
-
|
182
|
+
|
183
183
|
class And < Base
|
184
|
-
|
185
|
-
|
184
|
+
|
185
|
+
|
186
186
|
# Create an "and" boolean.
|
187
187
|
# The parameters are child processors whose return values should be
|
188
188
|
# combined with an AND operation.
|
189
|
-
|
189
|
+
|
190
190
|
def initialize(*children_)
|
191
191
|
@children = _interpret_processor_array(children_)
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
def begin_record(entry_)
|
195
195
|
@children.each do |child_|
|
196
196
|
return false unless child_.begin_record(entry_)
|
197
197
|
end
|
198
198
|
true
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
def end_record(entry_)
|
202
202
|
@children.each do |child_|
|
203
203
|
return false unless child_.end_record(entry_)
|
204
204
|
end
|
205
205
|
true
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
def message(entry_)
|
209
209
|
@children.each do |child_|
|
210
210
|
return false unless child_.message(entry_)
|
211
211
|
end
|
212
212
|
true
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
def attribute(entry_)
|
216
216
|
@children.each do |child_|
|
217
217
|
return false unless child_.attribute(entry_)
|
218
218
|
end
|
219
219
|
true
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
def unknown_data(entry_)
|
223
223
|
@children.each do |child_|
|
224
224
|
return false unless child_.unknown_data(entry_)
|
225
225
|
end
|
226
226
|
true
|
227
227
|
end
|
228
|
-
|
228
|
+
|
229
229
|
def finish
|
230
230
|
Util::ProcessorTools.collect_finish_values(@children)
|
231
231
|
end
|
232
|
-
|
233
|
-
|
232
|
+
|
233
|
+
|
234
234
|
end
|
235
|
-
|
236
|
-
|
235
|
+
|
236
|
+
|
237
237
|
# A boolean processor that returns true if and only if any of its child
|
238
238
|
# processors returns true. This version short-circuits the processing,
|
239
239
|
# so once one child returns true, subsequent children are not called
|
240
240
|
# at all.
|
241
|
-
#
|
241
|
+
#
|
242
242
|
# For example, this builds a processor that sends formatted log entries
|
243
243
|
# to STDOUT only if their level is at least INFO OR the progname is
|
244
244
|
# "rails":
|
245
|
-
#
|
245
|
+
#
|
246
246
|
# processor = Sawmill::EntryProcessor.build do
|
247
247
|
# If(Or(FilterByBasicFields(:level => :INFO),
|
248
248
|
# FilterByBasicFields(:progname => 'rails')),
|
249
249
|
# Format(STDOUT))
|
250
250
|
# end
|
251
|
-
|
251
|
+
|
252
252
|
class Or < Base
|
253
|
-
|
254
|
-
|
253
|
+
|
254
|
+
|
255
255
|
# Create an "or" boolean.
|
256
256
|
# The parameters are child processors whose return values should be
|
257
257
|
# combined with an OR operation.
|
258
|
-
|
258
|
+
|
259
259
|
def initialize(*children_)
|
260
260
|
@children = _interpret_processor_array(children_)
|
261
261
|
end
|
262
|
-
|
262
|
+
|
263
263
|
def begin_record(entry_)
|
264
264
|
@children.each do |child_|
|
265
265
|
return true if child_.begin_record(entry_)
|
266
266
|
end
|
267
267
|
false
|
268
268
|
end
|
269
|
-
|
269
|
+
|
270
270
|
def end_record(entry_)
|
271
271
|
@children.each do |child_|
|
272
272
|
return true if child_.end_record(entry_)
|
273
273
|
end
|
274
274
|
false
|
275
275
|
end
|
276
|
-
|
276
|
+
|
277
277
|
def message(entry_)
|
278
278
|
@children.each do |child_|
|
279
279
|
return true if child_.message(entry_)
|
280
280
|
end
|
281
281
|
false
|
282
282
|
end
|
283
|
-
|
283
|
+
|
284
284
|
def attribute(entry_)
|
285
285
|
@children.each do |child_|
|
286
286
|
return true if child_.attribute(entry_)
|
287
287
|
end
|
288
288
|
false
|
289
289
|
end
|
290
|
-
|
290
|
+
|
291
291
|
def unknown_data(entry_)
|
292
292
|
@children.each do |child_|
|
293
293
|
return true if child_.unknown_data(entry_)
|
294
294
|
end
|
295
295
|
false
|
296
296
|
end
|
297
|
-
|
297
|
+
|
298
298
|
def finish
|
299
299
|
Util::ProcessorTools.collect_finish_values(@children)
|
300
300
|
end
|
301
|
-
|
302
|
-
|
301
|
+
|
302
|
+
|
303
303
|
end
|
304
|
-
|
305
|
-
|
304
|
+
|
305
|
+
|
306
306
|
# A boolean processor that returns true if and only if all its child
|
307
307
|
# processors return true. This version does not short-circuit the
|
308
308
|
# processing, so all children are always called even if an early one
|
309
309
|
# returns false. Thus, this processor is also a good one to use as a
|
310
310
|
# multiplexor to simply run a bunch of processors.
|
311
|
-
#
|
311
|
+
#
|
312
312
|
# For example, this builds a processor that sends formatted log entries
|
313
313
|
# to STDOUT only if their level is at least INFO AND the progname is
|
314
314
|
# "rails":
|
315
|
-
#
|
315
|
+
#
|
316
316
|
# processor = Sawmill::EntryProcessor.build do
|
317
317
|
# If(All(FilterByBasicFields(:level => :INFO),
|
318
318
|
# FilterByBasicFields(:progname => 'rails')),
|
319
319
|
# Format(STDOUT))
|
320
320
|
# end
|
321
|
-
#
|
321
|
+
#
|
322
322
|
# This processor just formats both to STDOUT and STDERR:
|
323
|
-
#
|
323
|
+
#
|
324
324
|
# processor = Sawmill::EntryProcessor.build do
|
325
325
|
# All(Format(STDOUT), Format(STDERR))
|
326
326
|
# end
|
327
|
-
|
327
|
+
|
328
328
|
class All < Base
|
329
|
-
|
330
|
-
|
329
|
+
|
330
|
+
|
331
331
|
# Create an "all" boolean.
|
332
332
|
# The parameters are child processors whose return values should be
|
333
333
|
# combined with an AND operation.
|
334
|
-
|
334
|
+
|
335
335
|
def initialize(*children_)
|
336
336
|
@children = _interpret_processor_array(children_)
|
337
337
|
end
|
338
|
-
|
338
|
+
|
339
339
|
def begin_record(entry_)
|
340
340
|
@children.inject(true) do |result_, child_|
|
341
341
|
child_.begin_record(entry_) && result_
|
342
342
|
end
|
343
343
|
end
|
344
|
-
|
344
|
+
|
345
345
|
def end_record(entry_)
|
346
346
|
@children.inject(true) do |result_, child_|
|
347
347
|
child_.end_record(entry_) && result_
|
348
348
|
end
|
349
349
|
end
|
350
|
-
|
350
|
+
|
351
351
|
def message(entry_)
|
352
352
|
@children.inject(true) do |result_, child_|
|
353
353
|
child_.message(entry_) && result_
|
354
354
|
end
|
355
355
|
end
|
356
|
-
|
356
|
+
|
357
357
|
def attribute(entry_)
|
358
358
|
@children.inject(true) do |result_, child_|
|
359
359
|
child_.attribute(entry_) && result_
|
360
360
|
end
|
361
361
|
end
|
362
|
-
|
362
|
+
|
363
363
|
def unknown_data(entry_)
|
364
364
|
@children.inject(true) do |result_, child_|
|
365
365
|
child_.unknown_data(entry_) && result_
|
366
366
|
end
|
367
367
|
end
|
368
|
-
|
368
|
+
|
369
369
|
def finish
|
370
370
|
Util::ProcessorTools.collect_finish_values(@children)
|
371
371
|
end
|
372
|
-
|
373
|
-
|
372
|
+
|
373
|
+
|
374
374
|
end
|
375
|
-
|
376
|
-
|
375
|
+
|
376
|
+
|
377
377
|
# A boolean processor that returns true if and only if any of its child
|
378
378
|
# processors returns true. This version does not short-circuit the
|
379
379
|
# processing, so all children are always called even if an early one
|
380
380
|
# returns true.
|
381
|
-
#
|
381
|
+
#
|
382
382
|
# For example, this builds a processor that sends formatted log entries
|
383
383
|
# to STDOUT only if their level is at least INFO OR the progname is
|
384
384
|
# "rails":
|
385
|
-
#
|
385
|
+
#
|
386
386
|
# processor = Sawmill::EntryProcessor.build do
|
387
387
|
# If(Any(FilterByBasicFields(:level => :INFO),
|
388
388
|
# FilterByBasicFields(:progname => 'rails')),
|
389
389
|
# Format(STDOUT))
|
390
390
|
# end
|
391
|
-
|
391
|
+
|
392
392
|
class Any < Base
|
393
|
-
|
394
|
-
|
393
|
+
|
394
|
+
|
395
395
|
# Create an "any" boolean.
|
396
396
|
# The parameters are child processors whose return values should be
|
397
397
|
# combined with an OR operation.
|
398
|
-
|
398
|
+
|
399
399
|
def initialize(*children_)
|
400
400
|
@children = _interpret_processor_array(children_)
|
401
401
|
end
|
402
|
-
|
402
|
+
|
403
403
|
def begin_record(entry_)
|
404
404
|
@children.inject(false) do |result_, child_|
|
405
405
|
child_.begin_record(entry_) || result_
|
406
406
|
end
|
407
407
|
end
|
408
|
-
|
408
|
+
|
409
409
|
def end_record(entry_)
|
410
410
|
@children.inject(false) do |result_, child_|
|
411
411
|
child_.end_record(entry_) || result_
|
412
412
|
end
|
413
413
|
end
|
414
|
-
|
414
|
+
|
415
415
|
def message(entry_)
|
416
416
|
@children.inject(false) do |result_, child_|
|
417
417
|
child_.message(entry_) || result_
|
418
418
|
end
|
419
419
|
end
|
420
|
-
|
420
|
+
|
421
421
|
def attribute(entry_)
|
422
422
|
@children.inject(false) do |result_, child_|
|
423
423
|
child_.attribute(entry_) || result_
|
424
424
|
end
|
425
425
|
end
|
426
|
-
|
426
|
+
|
427
427
|
def unknown_data(entry_)
|
428
428
|
@children.inject(false) do |result_, child_|
|
429
429
|
child_.unknown_data(entry_) || result_
|
430
430
|
end
|
431
431
|
end
|
432
|
-
|
432
|
+
|
433
433
|
def finish
|
434
434
|
Util::ProcessorTools.collect_finish_values(@children)
|
435
435
|
end
|
436
|
-
|
437
|
-
|
436
|
+
|
437
|
+
|
438
438
|
end
|
439
|
-
|
440
|
-
|
439
|
+
|
440
|
+
|
441
441
|
end
|
442
|
-
|
442
|
+
|
443
443
|
end
|