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.
Files changed (53) hide show
  1. data/History.rdoc +7 -0
  2. data/Version +1 -1
  3. data/lib/sawmill.rb +6 -6
  4. data/lib/sawmill/entry.rb +108 -108
  5. data/lib/sawmill/entry_classifier.rb +19 -19
  6. data/lib/sawmill/entry_processor.rb +63 -63
  7. data/lib/sawmill/entry_processor/build_records.rb +39 -39
  8. data/lib/sawmill/entry_processor/compile_report.rb +32 -32
  9. data/lib/sawmill/entry_processor/conditionals.rb +110 -110
  10. data/lib/sawmill/entry_processor/count_entries.rb +27 -27
  11. data/lib/sawmill/entry_processor/filter_by_basic_fields.rb +32 -32
  12. data/lib/sawmill/entry_processor/filter_by_block.rb +28 -28
  13. data/lib/sawmill/entry_processor/format.rb +41 -36
  14. data/lib/sawmill/entry_processor/interpret_stats.rb +24 -24
  15. data/lib/sawmill/entry_processor/simple_queue.rb +38 -38
  16. data/lib/sawmill/errors.rb +28 -28
  17. data/lib/sawmill/interface.rb +51 -51
  18. data/lib/sawmill/level.rb +75 -75
  19. data/lib/sawmill/log_record_middleware.rb +21 -21
  20. data/lib/sawmill/logger.rb +94 -94
  21. data/lib/sawmill/multi_parser.rb +28 -28
  22. data/lib/sawmill/parser.rb +32 -32
  23. data/lib/sawmill/railtie.rb +31 -31
  24. data/lib/sawmill/record.rb +74 -74
  25. data/lib/sawmill/record_processor.rb +54 -54
  26. data/lib/sawmill/record_processor/compile_report.rb +32 -32
  27. data/lib/sawmill/record_processor/conditionals.rb +92 -92
  28. data/lib/sawmill/record_processor/count_records.rb +24 -24
  29. data/lib/sawmill/record_processor/decompose.rb +21 -21
  30. data/lib/sawmill/record_processor/filter_by_attributes.rb +22 -22
  31. data/lib/sawmill/record_processor/filter_by_block.rb +29 -29
  32. data/lib/sawmill/record_processor/filter_by_record_id.rb +22 -22
  33. data/lib/sawmill/record_processor/format.rb +24 -24
  34. data/lib/sawmill/record_processor/simple_queue.rb +44 -44
  35. data/lib/sawmill/rotater.rb +60 -60
  36. data/lib/sawmill/rotater/base.rb +28 -28
  37. data/lib/sawmill/rotater/date_based_log_file.rb +50 -50
  38. data/lib/sawmill/rotater/shifting_log_file.rb +34 -34
  39. data/lib/sawmill/stats_middleware.rb +21 -21
  40. data/lib/sawmill/stats_railtie.rb +33 -33
  41. data/lib/sawmill/util/heap.rb +41 -41
  42. data/lib/sawmill/util/processor_tools.rb +17 -17
  43. data/lib/sawmill/util/queue.rb +33 -33
  44. data/lib/sawmill/version.rb +9 -9
  45. data/test/tc_entry_processors.rb +27 -27
  46. data/test/tc_formatter_parser.rb +40 -40
  47. data/test/tc_levels.rb +27 -27
  48. data/test/tc_logger.rb +49 -49
  49. data/test/tc_multi_parser.rb +18 -18
  50. data/test/tc_record_processors.rb +21 -21
  51. data/test/tc_records.rb +39 -39
  52. data/test/tc_reports.rb +19 -19
  53. metadata +10 -5
data/test/tc_records.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Sawmill: tests on log record construction
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,19 +41,19 @@ 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 TestRecords < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
46
+
47
+
48
48
  def setup
49
49
  @records = ::Sawmill::RecordProcessor::SimpleQueue.new
50
50
  @logger = ::Sawmill::Logger.new(:processor => ::Sawmill::RecordBuilder.new(@records))
51
51
  @levels = ::Sawmill::STANDARD_LEVELS
52
52
  end
53
-
54
-
53
+
54
+
55
55
  # Test basic record creation
56
-
56
+
57
57
  def test_basic_create
58
58
  id_ = @logger.begin_record
59
59
  @logger.end_record
@@ -73,10 +73,10 @@ module Sawmill
73
73
  assert_equal('sawmill', entries_[1].progname)
74
74
  assert_equal(id_, entries_[1].record_id)
75
75
  end
76
-
77
-
76
+
77
+
78
78
  # Test record messages
79
-
79
+
80
80
  def test_messages
81
81
  id_ = @logger.begin_record
82
82
  @logger.info('Hello 1')
@@ -97,12 +97,12 @@ module Sawmill
97
97
  assert_equal(id_, meessages_[1].record_id)
98
98
  assert_equal('Hello 2', meessages_[1].message)
99
99
  end
100
-
101
-
100
+
101
+
102
102
  # Test record attributes
103
-
103
+
104
104
  def test_attributes
105
- id_ = @logger.begin_record
105
+ @logger.begin_record
106
106
  @logger.attribute('color', 'blue')
107
107
  @logger.attribute('size', 'small')
108
108
  @logger.attribute(:color, 'red')
@@ -114,12 +114,12 @@ module Sawmill
114
114
  assert_equal('small', record_.attribute('size'))
115
115
  assert_equal('red', record_.attribute('color'))
116
116
  end
117
-
118
-
117
+
118
+
119
119
  # Test record multi-attributes
120
-
120
+
121
121
  def test_multi_attributes
122
- id_ = @logger.begin_record
122
+ @logger.begin_record
123
123
  @logger.append_attribute('color', 'blue')
124
124
  @logger.append_attribute('size', 'small')
125
125
  @logger.append_attribute(:color, 'red')
@@ -131,10 +131,10 @@ module Sawmill
131
131
  assert_equal(['small'], record_.attribute('size'))
132
132
  assert_equal(['blue', 'red'], record_.attribute('color'))
133
133
  end
134
-
135
-
134
+
135
+
136
136
  # Test record decomposition
137
-
137
+
138
138
  def _test_decompose
139
139
  entries_ = ::Sawmill::EntryProcessor::SimpleQueue.new
140
140
  id_ = @logger.begin_record
@@ -149,60 +149,60 @@ module Sawmill
149
149
  record_ = @records.dequeue
150
150
  assert_equal(9, record_.entry_count)
151
151
  record_.decompose(entries_)
152
-
152
+
153
153
  entry_ = entries_.dequeue
154
154
  assert_equal(:begin_record, entry_.type)
155
155
  assert_equal(@levels.get(:ANY), entry_.level)
156
156
  assert_equal('sawmill', entry_.progname)
157
157
  assert_equal(id_, entry_.record_id)
158
-
158
+
159
159
  entry_ = entries_.dequeue
160
160
  assert_equal(:message, entry_.type)
161
161
  assert_equal(@levels.get(:INFO), entry_.level)
162
162
  assert_equal('sawmill', entry_.progname)
163
163
  assert_equal(id_, entry_.record_id)
164
164
  assert_equal('Hello 1', entry_.message)
165
-
165
+
166
166
  entry_ = entries_.dequeue
167
167
  assert_equal(:attribute, entry_.type)
168
168
  assert_equal('color', entry_.key)
169
169
  assert_equal('blue', entry_.value)
170
-
170
+
171
171
  entry_ = entries_.dequeue
172
172
  assert_equal(:attribute, entry_.type)
173
173
  assert_equal('size', entry_.key)
174
174
  assert_equal('small', entry_.value)
175
-
175
+
176
176
  entry_ = entries_.dequeue
177
177
  assert_equal(:multi_attribute, entry_.type)
178
178
  assert_equal('shape', entry_.key)
179
179
  assert_equal('round', entry_.value)
180
-
180
+
181
181
  entry_ = entries_.dequeue
182
182
  assert_equal(:message, entry_.type)
183
183
  assert_equal(@levels.get(:ERROR), entry_.level)
184
184
  assert_equal('rails', entry_.progname)
185
185
  assert_equal('Hello 2', entry_.message)
186
-
186
+
187
187
  entry_ = entries_.dequeue
188
188
  assert_equal(:attribute, entry_.type)
189
189
  assert_equal('color', entry_.key)
190
190
  assert_equal('red', entry_.value)
191
-
191
+
192
192
  entry_ = entries_.dequeue
193
193
  assert_equal(:multi_attribute, entry_.type)
194
194
  assert_equal('shape', entry_.key)
195
195
  assert_equal('pointy', entry_.value)
196
-
196
+
197
197
  entry_ = entries_.dequeue
198
198
  assert_equal(:end_record, entry_.type)
199
199
  assert_equal(id_, entry_.record_id)
200
-
200
+
201
201
  assert_equal(0, entries_.size)
202
202
  end
203
-
204
-
203
+
204
+
205
205
  end
206
-
206
+
207
207
  end
208
208
  end
data/test/tc_reports.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Sawmill: tests 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
@@ -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
-
45
- class TestMultiParser < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
44
+
45
+ class TestReports < ::Test::Unit::TestCase # :nodoc:
46
+
47
+
48
48
  def setup
49
49
  @levels = ::Sawmill::STANDARD_LEVELS
50
50
  end
51
-
52
-
51
+
52
+
53
53
  # Test entry report.
54
-
54
+
55
55
  def test_entry_report
56
56
  processor_ = EntryProcessor.build do
57
57
  CompileReport(If(FilterByBasicFields(:level => :WARN),
@@ -68,10 +68,10 @@ module Sawmill
68
68
  logger_.info("hello 6")
69
69
  assert_equal("warn: 3\nerror: 2", logger_.close)
70
70
  end
71
-
72
-
71
+
72
+
73
73
  # Test record report.
74
-
74
+
75
75
  def test_record_report
76
76
  processor_ = RecordProcessor.build do
77
77
  CompileReport(If(FilterByAttributes('user' => 'daniel'),
@@ -94,9 +94,9 @@ module Sawmill
94
94
  logger_.end_record
95
95
  assert_equal("daniel: 2\nseattle: 1", logger_.close)
96
96
  end
97
-
98
-
97
+
98
+
99
99
  end
100
-
100
+
101
101
  end
102
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sawmill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-25 00:00:00.000000000Z
12
+ date: 2012-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blockenspiel
16
- requirement: &2164525840 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 0.4.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164525840
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.3
25
30
  description: Sawmill is a logging and log analysis system for Ruby. It extends the
26
31
  basic Ruby logging facility with log records and parsing abilities.
27
32
  email: dazuma@gmail.com
@@ -104,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
109
  version: 1.3.1
105
110
  requirements: []
106
111
  rubyforge_project: virtuoso
107
- rubygems_version: 1.8.7
112
+ rubygems_version: 1.8.24
108
113
  signing_key:
109
114
  specification_version: 3
110
115
  summary: Sawmill is a logging and log analysis system for Ruby.