sawmill 0.1.15 → 0.1.16
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/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
data/test/tc_levels.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill: tests on the levels mechanism
|
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
|
@@ -41,17 +41,17 @@ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/sawmill.rb")
|
|
41
41
|
|
42
42
|
module Sawmill
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestLevels < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def setup
|
49
49
|
@levels = ::Sawmill::STANDARD_LEVELS
|
50
50
|
end
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
|
53
53
|
# Test equivalence of standard level names and legacy logger level constants
|
54
|
-
|
54
|
+
|
55
55
|
def test_standard_names_vs_legacy_constants
|
56
56
|
assert_equal(@levels.get(:DEBUG), @levels.get(::Logger::DEBUG))
|
57
57
|
assert_not_equal(@levels.get(:DEBUG), @levels.get(::Logger::INFO))
|
@@ -61,20 +61,20 @@ module Sawmill
|
|
61
61
|
assert_equal(@levels.get(:FATAL), @levels.get(::Logger::FATAL))
|
62
62
|
assert_equal(@levels.get(:ANY), @levels.get(::Logger::UNKNOWN))
|
63
63
|
end
|
64
|
-
|
65
|
-
|
64
|
+
|
65
|
+
|
66
66
|
# Test special levels in the standard set
|
67
|
-
|
67
|
+
|
68
68
|
def test_special_standard_levels
|
69
69
|
assert_equal(@levels.get(:DEBUG), @levels.lowest)
|
70
70
|
assert_equal(@levels.get(:INFO), @levels.default)
|
71
71
|
assert_equal(@levels.get(:ANY), @levels.highest)
|
72
72
|
assert_equal(@levels.get(nil), @levels.default)
|
73
73
|
end
|
74
|
-
|
75
|
-
|
74
|
+
|
75
|
+
|
76
76
|
# Test method lookup of standard levels
|
77
|
-
|
77
|
+
|
78
78
|
def test_standard_method_lookup
|
79
79
|
assert_equal(@levels.get(:DEBUG), @levels.lookup_method(:debug))
|
80
80
|
assert_equal(@levels.get(:INFO), @levels.lookup_method(:info))
|
@@ -84,20 +84,20 @@ module Sawmill
|
|
84
84
|
assert_equal(@levels.get(:ANY), @levels.lookup_method(:any))
|
85
85
|
assert_equal(@levels.get(:ANY), @levels.lookup_method(:unknown))
|
86
86
|
end
|
87
|
-
|
88
|
-
|
87
|
+
|
88
|
+
|
89
89
|
# Test comparison of standard levels
|
90
|
-
|
90
|
+
|
91
91
|
def test_standard_comparisons
|
92
92
|
assert(@levels.get(:DEBUG) < @levels.get(:INFO))
|
93
93
|
assert(@levels.get(:ANY) > @levels.get(:FATAL))
|
94
94
|
assert(@levels.get(:ERROR) >= @levels.get(:DEBUG))
|
95
95
|
assert(@levels.get(:WARN) >= @levels.get(:WARN))
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
# Test custom level group
|
100
|
-
|
100
|
+
|
101
101
|
def test_custom_group
|
102
102
|
group_ = ::Sawmill::LevelGroup.new do |g_|
|
103
103
|
g_.add(:LOW, :methods => 'low')
|
@@ -111,9 +111,9 @@ module Sawmill
|
|
111
111
|
assert_equal(group_.highest, group_.get(3))
|
112
112
|
assert_not_equal(@levels.lowest, group_.lowest)
|
113
113
|
end
|
114
|
-
|
115
|
-
|
114
|
+
|
115
|
+
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
end
|
119
119
|
end
|
data/test/tc_logger.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill: tests on the basic logger
|
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
|
@@ -40,19 +40,19 @@ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/sawmill.rb")
|
|
40
40
|
|
41
41
|
module Sawmill
|
42
42
|
module Tests # :nodoc:
|
43
|
-
|
43
|
+
|
44
44
|
class TestLogger < ::Test::Unit::TestCase # :nodoc:
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
def setup
|
48
48
|
@entries = ::Sawmill::EntryProcessor::SimpleQueue.new
|
49
49
|
@logger = ::Sawmill::Logger.new(:processor => @entries)
|
50
50
|
@levels = ::Sawmill::STANDARD_LEVELS
|
51
51
|
end
|
52
|
-
|
53
|
-
|
52
|
+
|
53
|
+
|
54
54
|
# Test basic log messages using the add method
|
55
|
-
|
55
|
+
|
56
56
|
def test_add
|
57
57
|
@logger.add(:INFO, 'Hello 1')
|
58
58
|
entry_ = @entries.dequeue
|
@@ -60,28 +60,28 @@ module Sawmill
|
|
60
60
|
assert_equal('sawmill', entry_.progname)
|
61
61
|
assert_nil(entry_.record_id)
|
62
62
|
assert_equal('Hello 1', entry_.message)
|
63
|
-
|
63
|
+
|
64
64
|
@logger.add(:ERROR, 'Hello 2', 'altprog')
|
65
65
|
entry_ = @entries.dequeue
|
66
66
|
assert_equal(@levels.get(:ERROR), entry_.level)
|
67
67
|
assert_equal('altprog', entry_.progname)
|
68
68
|
assert_nil(entry_.record_id)
|
69
69
|
assert_equal('Hello 2', entry_.message)
|
70
|
-
|
70
|
+
|
71
71
|
@logger.add(:WARN){ 'Hello 3' }
|
72
72
|
entry_ = @entries.dequeue
|
73
73
|
assert_equal(@levels.get(:WARN), entry_.level)
|
74
74
|
assert_equal('sawmill', entry_.progname)
|
75
75
|
assert_nil(entry_.record_id)
|
76
76
|
assert_equal('Hello 3', entry_.message)
|
77
|
-
|
77
|
+
|
78
78
|
@logger.add(:DEBUG, 'Hello 4')
|
79
79
|
assert_equal(0, @entries.size)
|
80
80
|
end
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
|
83
83
|
# Test convenience logging methods
|
84
|
-
|
84
|
+
|
85
85
|
def test_convenience_add
|
86
86
|
@logger.info('Hello 1')
|
87
87
|
entry_ = @entries.dequeue
|
@@ -89,53 +89,53 @@ module Sawmill
|
|
89
89
|
assert_equal('sawmill', entry_.progname)
|
90
90
|
assert_nil(entry_.record_id)
|
91
91
|
assert_equal('Hello 1', entry_.message)
|
92
|
-
|
92
|
+
|
93
93
|
@logger.error('altprog'){ 'Hello 2' }
|
94
94
|
entry_ = @entries.dequeue
|
95
95
|
assert_equal(@levels.get(:ERROR), entry_.level)
|
96
96
|
assert_equal('altprog', entry_.progname)
|
97
97
|
assert_nil(entry_.record_id)
|
98
98
|
assert_equal('Hello 2', entry_.message)
|
99
|
-
|
99
|
+
|
100
100
|
@logger.warn(){ 'Hello 3' }
|
101
101
|
entry_ = @entries.dequeue
|
102
102
|
assert_equal(@levels.get(:WARN), entry_.level)
|
103
103
|
assert_equal('sawmill', entry_.progname)
|
104
104
|
assert_nil(entry_.record_id)
|
105
105
|
assert_equal('Hello 3', entry_.message)
|
106
|
-
|
106
|
+
|
107
107
|
@logger.debug('Hello 4')
|
108
108
|
assert_equal(0, @entries.size)
|
109
|
-
|
109
|
+
|
110
110
|
@logger.fatal('Hello 5')
|
111
111
|
entry_ = @entries.dequeue
|
112
112
|
assert_equal(@levels.get(:FATAL), entry_.level)
|
113
113
|
assert_equal('sawmill', entry_.progname)
|
114
114
|
assert_nil(entry_.record_id)
|
115
115
|
assert_equal('Hello 5', entry_.message)
|
116
|
-
|
116
|
+
|
117
117
|
@logger.any('Hello 6')
|
118
118
|
entry_ = @entries.dequeue
|
119
119
|
assert_equal(@levels.get(:ANY), entry_.level)
|
120
120
|
assert_equal('sawmill', entry_.progname)
|
121
121
|
assert_nil(entry_.record_id)
|
122
122
|
assert_equal('Hello 6', entry_.message)
|
123
|
-
|
123
|
+
|
124
124
|
@logger.unknown('Hello 7')
|
125
125
|
entry_ = @entries.dequeue
|
126
126
|
assert_equal(@levels.get(:ANY), entry_.level)
|
127
127
|
assert_equal('sawmill', entry_.progname)
|
128
128
|
assert_nil(entry_.record_id)
|
129
129
|
assert_equal('Hello 7', entry_.message)
|
130
|
-
|
130
|
+
|
131
131
|
assert_raise(::NoMethodError) do
|
132
132
|
@logger.always('Hello 8')
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
136
|
-
|
135
|
+
|
136
|
+
|
137
137
|
# Test current level queries
|
138
|
-
|
138
|
+
|
139
139
|
def test_level_queries
|
140
140
|
assert_equal(@levels.get(:INFO), @logger.level)
|
141
141
|
assert_equal(false, @logger.debug?)
|
@@ -162,10 +162,10 @@ module Sawmill
|
|
162
162
|
assert_equal(true, @logger.fatal?)
|
163
163
|
assert_equal(true, @logger.any?)
|
164
164
|
end
|
165
|
-
|
166
|
-
|
165
|
+
|
166
|
+
|
167
167
|
# Test setting the progname
|
168
|
-
|
168
|
+
|
169
169
|
def test_setting_progname
|
170
170
|
assert_equal('sawmill', @logger.progname)
|
171
171
|
@logger.info('Hello 1')
|
@@ -179,10 +179,10 @@ module Sawmill
|
|
179
179
|
assert_equal('rails', entry_.progname)
|
180
180
|
assert_equal('Hello 2', entry_.message)
|
181
181
|
end
|
182
|
-
|
183
|
-
|
182
|
+
|
183
|
+
|
184
184
|
# Test record delimiters
|
185
|
-
|
185
|
+
|
186
186
|
def test_record_delimiters_auto_id
|
187
187
|
id_ = @logger.begin_record
|
188
188
|
assert_match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, id_)
|
@@ -206,10 +206,10 @@ module Sawmill
|
|
206
206
|
assert_equal(id_, entry_.record_id)
|
207
207
|
assert_equal(0, @entries.size)
|
208
208
|
end
|
209
|
-
|
210
|
-
|
209
|
+
|
210
|
+
|
211
211
|
# Test record delimiters
|
212
|
-
|
212
|
+
|
213
213
|
def test_record_delimiters_custom_id
|
214
214
|
@logger.begin_record('1234')
|
215
215
|
@logger.info('Hello 2')
|
@@ -232,10 +232,10 @@ module Sawmill
|
|
232
232
|
assert_equal('1234', entry_.record_id)
|
233
233
|
assert_equal(0, @entries.size)
|
234
234
|
end
|
235
|
-
|
236
|
-
|
235
|
+
|
236
|
+
|
237
237
|
# Test record delimiters
|
238
|
-
|
238
|
+
|
239
239
|
def test_message_outside_record
|
240
240
|
@logger.begin_record
|
241
241
|
@logger.end_record
|
@@ -252,10 +252,10 @@ module Sawmill
|
|
252
252
|
assert_equal('Hello 3', entry_.message)
|
253
253
|
assert_equal(0, @entries.size)
|
254
254
|
end
|
255
|
-
|
256
|
-
|
255
|
+
|
256
|
+
|
257
257
|
# Test attribute
|
258
|
-
|
258
|
+
|
259
259
|
def test_attribute
|
260
260
|
id_ = @logger.begin_record
|
261
261
|
@logger.set_attribute('user', 'daniel')
|
@@ -276,10 +276,10 @@ module Sawmill
|
|
276
276
|
assert_equal(id_, entry_.record_id)
|
277
277
|
assert_equal(0, @entries.size)
|
278
278
|
end
|
279
|
-
|
280
|
-
|
279
|
+
|
280
|
+
|
281
281
|
# Test multi-attribute
|
282
|
-
|
282
|
+
|
283
283
|
def test_multi_attribute
|
284
284
|
id_ = @logger.begin_record
|
285
285
|
@logger.append_attribute('event', 'click')
|
@@ -309,9 +309,9 @@ module Sawmill
|
|
309
309
|
assert_equal(id_, entry_.record_id)
|
310
310
|
assert_equal(0, @entries.size)
|
311
311
|
end
|
312
|
-
|
313
|
-
|
312
|
+
|
313
|
+
|
314
314
|
end
|
315
|
-
|
315
|
+
|
316
316
|
end
|
317
317
|
end
|
data/test/tc_multi_parser.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill: tests multi-parser
|
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
|
@@ -41,15 +41,15 @@ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/sawmill.rb")
|
|
41
41
|
|
42
42
|
module Sawmill
|
43
43
|
module Tests # :nodoc:
|
44
|
-
|
44
|
+
|
45
45
|
class TestMultiParser < ::Test::Unit::TestCase # :nodoc:
|
46
|
-
|
47
|
-
|
46
|
+
|
47
|
+
|
48
48
|
def setup
|
49
49
|
@levels = ::Sawmill::STANDARD_LEVELS
|
50
50
|
end
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
|
53
53
|
def _get_io_array(entry_groups_)
|
54
54
|
strings_ = []
|
55
55
|
entry_groups_.each do |entries_|
|
@@ -62,13 +62,13 @@ module Sawmill
|
|
62
62
|
end
|
63
63
|
strings_.map{ |str_| ::StringIO.new(str_) }
|
64
64
|
end
|
65
|
-
|
66
|
-
|
65
|
+
|
66
|
+
|
67
67
|
# Test interleaved entries including unknown data entries.
|
68
68
|
# Makes sure they come out in the right order.
|
69
|
-
|
69
|
+
|
70
70
|
def test_interleaved_entries
|
71
|
-
base_time_ = Time.
|
71
|
+
base_time_ = ::Time.gm(2012, 3, 14, 15, 9, 27)
|
72
72
|
entries_ = []
|
73
73
|
2.times do |i_|
|
74
74
|
entries_ << ::Sawmill::Entry::UnknownData.new("Unknown #{i_}")
|
@@ -81,9 +81,9 @@ module Sawmill
|
|
81
81
|
::Sawmill::MultiParser.new(io_array_, queue_).parse_all
|
82
82
|
assert_equal([entries_[0], entries_[2], entries_[3], entries_[4], entries_[1], entries_[5]], queue_.dequeue_all)
|
83
83
|
end
|
84
|
-
|
85
|
-
|
84
|
+
|
85
|
+
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
end
|
89
89
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill: tests on record processors
|
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
|
@@ -40,18 +40,18 @@ require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/sawmill.rb")
|
|
40
40
|
|
41
41
|
module Sawmill
|
42
42
|
module Tests # :nodoc:
|
43
|
-
|
43
|
+
|
44
44
|
class TestRecordProcessors < ::Test::Unit::TestCase # :nodoc:
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
def setup
|
48
48
|
@records = ::Sawmill::RecordProcessor::SimpleQueue.new
|
49
49
|
@levels = ::Sawmill::STANDARD_LEVELS
|
50
50
|
end
|
51
|
-
|
52
|
-
|
51
|
+
|
52
|
+
|
53
53
|
# Test a basic filter that checks the record ID
|
54
|
-
|
54
|
+
|
55
55
|
def test_basic_record_id_filter
|
56
56
|
processor_ = ::Sawmill::RecordProcessor::build do
|
57
57
|
If(FilterByRecordID('12345678'), @records)
|
@@ -66,10 +66,10 @@ module Sawmill
|
|
66
66
|
assert_equal('12345678', @records.dequeue.record_id)
|
67
67
|
assert_equal(0, @records.size)
|
68
68
|
end
|
69
|
-
|
70
|
-
|
69
|
+
|
70
|
+
|
71
71
|
# Test a basic filter that checks an attribute
|
72
|
-
|
72
|
+
|
73
73
|
def test_basic_attribute_filter
|
74
74
|
processor_ = ::Sawmill::RecordProcessor::build do
|
75
75
|
If(FilterByAttributes('user' => 'daniel'), @records)
|
@@ -87,10 +87,10 @@ module Sawmill
|
|
87
87
|
assert_equal('2', @records.dequeue.record_id)
|
88
88
|
assert_equal(0, @records.size)
|
89
89
|
end
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
|
92
92
|
# Test a basic filter that checks two attributes
|
93
|
-
|
93
|
+
|
94
94
|
def test_two_attributes_filter
|
95
95
|
processor_ = ::Sawmill::RecordProcessor::build do
|
96
96
|
If(FilterByAttributes('user' => 'daniel', 'type' => 'admin'), @records)
|
@@ -110,9 +110,9 @@ module Sawmill
|
|
110
110
|
assert_equal('3', @records.dequeue.record_id)
|
111
111
|
assert_equal(0, @records.size)
|
112
112
|
end
|
113
|
-
|
114
|
-
|
113
|
+
|
114
|
+
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
end
|
118
118
|
end
|