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
data/History.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
=== 0.1.16 / 2012-06-04
|
2
|
+
|
3
|
+
* The :local_time and :iso_8601_time arguments to Sawmill::EntryProcessor::Format didn't have their advertised effect. Fixed.
|
4
|
+
* The :emit_incomplete_records_on_finish argument to Sawmill::EntryProcessor::BuildRecords didn't have its advertised effect. Fixed.
|
5
|
+
* Fixed a few warnings.
|
6
|
+
* Travis CI integration.
|
7
|
+
|
1
8
|
=== 0.1.15 / 2011-10-24
|
2
9
|
|
3
10
|
* 0.1.14 was inadvertently released before testing was complete. Fixed several stats logs issues.
|
data/Version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
data/lib/sawmill.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill entry point
|
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
|
data/lib/sawmill/entry.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Sawmill log entry classes
|
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,58 +35,58 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module Sawmill
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
|
40
40
|
# This module is a namespace for log entry classes.
|
41
|
-
|
41
|
+
|
42
42
|
module Entry
|
43
|
-
|
44
|
-
|
43
|
+
|
44
|
+
|
45
45
|
# A log entry that doesn't conform to sawmill's format.
|
46
|
-
|
46
|
+
|
47
47
|
class UnknownData
|
48
|
-
|
49
|
-
|
48
|
+
|
49
|
+
|
50
50
|
def initialize(line_)
|
51
51
|
@line = line_.to_s
|
52
52
|
end
|
53
|
-
|
54
|
-
|
53
|
+
|
54
|
+
|
55
55
|
# Returns <tt>:unknown_data</tt>
|
56
56
|
def type; :unknown_data end
|
57
|
-
|
57
|
+
|
58
58
|
# The line in the logfile as a raw string
|
59
59
|
attr_reader :line
|
60
|
-
|
61
|
-
|
60
|
+
|
61
|
+
|
62
62
|
def to_s # :nodoc:
|
63
63
|
"#{type}: #{@line}"
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def inspect # :nodoc:
|
67
67
|
"#<#{self.class}:0x#{object_id.to_s(16)} line=#{@line.inspect}>"
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def eql?(obj_) # :nodoc:
|
71
71
|
obj_.kind_of?(Entry::UnknownData) && obj_.line == @line
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def ==(obj_) # :nodoc:
|
75
75
|
eql?(obj_)
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def hash # :nodoc:
|
79
79
|
type.hash ^ @line.hash
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
end
|
83
|
-
|
84
|
-
|
83
|
+
|
84
|
+
|
85
85
|
# A log entry containing a standard log message.
|
86
|
-
|
86
|
+
|
87
87
|
class Message
|
88
|
-
|
89
|
-
|
88
|
+
|
89
|
+
|
90
90
|
def initialize(level_, timestamp_, progname_, record_id_, message_)
|
91
91
|
@level = level_
|
92
92
|
@timestamp = timestamp_
|
@@ -96,56 +96,56 @@ module Sawmill
|
|
96
96
|
@record_id.gsub!(/\s+/, '') if @record_id
|
97
97
|
@message = message_.to_s
|
98
98
|
end
|
99
|
-
|
100
|
-
|
99
|
+
|
100
|
+
|
101
101
|
# Returns <tt>:message</tt>
|
102
102
|
def type; :message; end
|
103
|
-
|
103
|
+
|
104
104
|
# The log level as a Sawmill::Level object
|
105
105
|
attr_reader :level
|
106
|
-
|
106
|
+
|
107
107
|
# The timestamp as a Time object
|
108
108
|
attr_reader :timestamp
|
109
|
-
|
109
|
+
|
110
110
|
# The progname as a string
|
111
111
|
attr_reader :progname
|
112
|
-
|
112
|
+
|
113
113
|
# The record ID as a string
|
114
114
|
attr_reader :record_id
|
115
|
-
|
115
|
+
|
116
116
|
# The message as a string
|
117
117
|
attr_reader :message
|
118
|
-
|
119
|
-
|
118
|
+
|
119
|
+
|
120
120
|
def to_s # :nodoc:
|
121
121
|
"#{type}: #{@message}"
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def inspect # :nodoc:
|
125
125
|
"#<#{self.class}:0x#{object_id.to_s(16)} level=#{@level.name} time=#{@timestamp.to_s.inspect} progname=#{@progname.inspect} record_id=#{@record_id.inspect} message=#{@message.inspect}>"
|
126
126
|
end
|
127
|
-
|
127
|
+
|
128
128
|
def eql?(obj_) # :nodoc:
|
129
129
|
obj_.kind_of?(Entry::Message) && obj_.level == @level && obj_.timestamp == @timestamp && obj_.progname == @progname && obj_.record_id == @record_id && obj_.message == @message
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
def ==(obj_) # :nodoc:
|
133
133
|
eql?(obj_)
|
134
134
|
end
|
135
|
-
|
135
|
+
|
136
136
|
def hash # :nodoc:
|
137
137
|
type.hash ^ @level.hash ^ @timestamp.hash ^ @progname.hash ^ @record_id.hash ^ @message.hash
|
138
138
|
end
|
139
|
-
|
140
|
-
|
139
|
+
|
140
|
+
|
141
141
|
end
|
142
|
-
|
143
|
-
|
142
|
+
|
143
|
+
|
144
144
|
# A log entry signalling the beginning of a log record.
|
145
|
-
|
145
|
+
|
146
146
|
class BeginRecord
|
147
|
-
|
148
|
-
|
147
|
+
|
148
|
+
|
149
149
|
def initialize(level_, timestamp_, progname_, record_id_)
|
150
150
|
@level = level_
|
151
151
|
@timestamp = timestamp_
|
@@ -154,106 +154,106 @@ module Sawmill
|
|
154
154
|
@record_id = record_id_.nil? ? nil : record_id_.to_s
|
155
155
|
@record_id.gsub!(/\s+/, '') if @record_id
|
156
156
|
end
|
157
|
-
|
158
|
-
|
157
|
+
|
158
|
+
|
159
159
|
# Returns <tt>:begin_record</tt>
|
160
160
|
def type; :begin_record; end
|
161
|
-
|
161
|
+
|
162
162
|
# The log level as a Sawmill::Level object
|
163
163
|
attr_reader :level
|
164
|
-
|
164
|
+
|
165
165
|
# The timestamp as a Time object
|
166
166
|
attr_reader :timestamp
|
167
|
-
|
167
|
+
|
168
168
|
# The progname as a string
|
169
169
|
attr_reader :progname
|
170
|
-
|
170
|
+
|
171
171
|
# The record ID as a string
|
172
172
|
attr_reader :record_id
|
173
|
-
|
174
|
-
|
173
|
+
|
174
|
+
|
175
175
|
def to_s # :nodoc:
|
176
176
|
"#{type}: #{@record_id}"
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
def inspect # :nodoc:
|
180
180
|
"#<#{self.class}:0x#{object_id.to_s(16)} level=#{@level.name} time=#{@timestamp.to_s.inspect} progname=#{@progname.inspect} record_id=#{@record_id.inspect}>"
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
def eql?(obj_) # :nodoc:
|
184
184
|
obj_.kind_of?(Entry::BeginRecord) && obj_.level == @level && obj_.timestamp == @timestamp && obj_.progname == @progname && obj_.record_id == @record_id
|
185
185
|
end
|
186
|
-
|
186
|
+
|
187
187
|
def ==(obj_) # :nodoc:
|
188
188
|
eql?(obj_)
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
def hash # :nodoc:
|
192
192
|
type.hash ^ @level.hash ^ @timestamp.hash ^ @progname.hash ^ @record_id.hash
|
193
193
|
end
|
194
|
-
|
195
|
-
|
194
|
+
|
195
|
+
|
196
196
|
end
|
197
|
-
|
198
|
-
|
197
|
+
|
198
|
+
|
199
199
|
# A log entry signalling the end of a log record.
|
200
|
-
|
200
|
+
|
201
201
|
class EndRecord
|
202
|
-
|
203
|
-
|
202
|
+
|
203
|
+
|
204
204
|
def initialize(level_, timestamp_, progname_, record_id_)
|
205
205
|
@level = level_
|
206
206
|
@timestamp = timestamp_
|
207
207
|
@progname = progname_.to_s
|
208
208
|
@record_id = record_id_.nil? ? nil : record_id_.to_s
|
209
209
|
end
|
210
|
-
|
211
|
-
|
210
|
+
|
211
|
+
|
212
212
|
# Returns <tt>:end_record</tt>
|
213
213
|
def type; :end_record; end
|
214
|
-
|
214
|
+
|
215
215
|
# The log level as a Sawmill::Level object
|
216
216
|
attr_reader :level
|
217
|
-
|
217
|
+
|
218
218
|
# The timestamp as a Time object
|
219
219
|
attr_reader :timestamp
|
220
|
-
|
220
|
+
|
221
221
|
# The progname as a string
|
222
222
|
attr_reader :progname
|
223
|
-
|
223
|
+
|
224
224
|
# The record ID as a string
|
225
225
|
attr_reader :record_id
|
226
|
-
|
227
|
-
|
226
|
+
|
227
|
+
|
228
228
|
def to_s # :nodoc:
|
229
229
|
"#{type}: #{@record_id}"
|
230
230
|
end
|
231
|
-
|
231
|
+
|
232
232
|
def inspect # :nodoc:
|
233
233
|
"#<#{self.class}:0x#{object_id.to_s(16)} level=#{@level.name} time=#{@timestamp.to_s.inspect} progname=#{@progname.inspect} record_id=#{@record_id.inspect}>"
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
def eql?(obj_) # :nodoc:
|
237
237
|
obj_.kind_of?(Entry::EndRecord) && obj_.level == @level && obj_.timestamp == @timestamp && obj_.progname == @progname && obj_.record_id == @record_id
|
238
238
|
end
|
239
|
-
|
239
|
+
|
240
240
|
def ==(obj_) # :nodoc:
|
241
241
|
eql?(obj_)
|
242
242
|
end
|
243
|
-
|
243
|
+
|
244
244
|
def hash # :nodoc:
|
245
245
|
type.hash ^ @level.hash ^ @timestamp.hash ^ @progname.hash ^ @record_id.hash
|
246
246
|
end
|
247
|
-
|
248
|
-
|
247
|
+
|
248
|
+
|
249
249
|
end
|
250
|
-
|
251
|
-
|
250
|
+
|
251
|
+
|
252
252
|
# A log entry containing a log record attribute.
|
253
|
-
|
253
|
+
|
254
254
|
class Attribute
|
255
|
-
|
256
|
-
|
255
|
+
|
256
|
+
|
257
257
|
def initialize(level_, timestamp_, progname_, record_id_, key_, value_, operation_=nil)
|
258
258
|
@level = level_
|
259
259
|
@timestamp = timestamp_
|
@@ -266,58 +266,58 @@ module Sawmill
|
|
266
266
|
@value = value_.to_s
|
267
267
|
@operation = operation_ || :set
|
268
268
|
end
|
269
|
-
|
270
|
-
|
269
|
+
|
270
|
+
|
271
271
|
# Returns <tt>:attribute</tt>
|
272
272
|
def type; :attribute; end
|
273
|
-
|
273
|
+
|
274
274
|
# The log level as a Sawmill::Level object
|
275
275
|
attr_reader :level
|
276
|
-
|
276
|
+
|
277
277
|
# The timestamp as a Time object
|
278
278
|
attr_reader :timestamp
|
279
|
-
|
279
|
+
|
280
280
|
# The progname as a string
|
281
281
|
attr_reader :progname
|
282
|
-
|
282
|
+
|
283
283
|
# The record ID as a string
|
284
284
|
attr_reader :record_id
|
285
|
-
|
285
|
+
|
286
286
|
# The operation, which can currently be :set or :append
|
287
287
|
attr_reader :operation
|
288
|
-
|
288
|
+
|
289
289
|
# The attribute key as a string
|
290
290
|
attr_reader :key
|
291
|
-
|
291
|
+
|
292
292
|
# The attribute value as a string
|
293
293
|
attr_reader :value
|
294
|
-
|
295
|
-
|
294
|
+
|
295
|
+
|
296
296
|
def to_s # :nodoc:
|
297
297
|
"#{type}: #{@key}=#{@value.inspect}"
|
298
298
|
end
|
299
|
-
|
299
|
+
|
300
300
|
def inspect # :nodoc:
|
301
301
|
"#<#{self.class}:0x#{object_id.to_s(16)} level=#{@level.name} time=#{@timestamp.to_s.inspect} progname=#{@progname.inspect} record_id=#{@record_id.inspect} operation=#{@operation} key=#{@key.inspect} value=#{@value.inspect}>"
|
302
302
|
end
|
303
|
-
|
303
|
+
|
304
304
|
def eql?(obj_) # :nodoc:
|
305
305
|
obj_.kind_of?(Entry::Attribute) && obj_.level == @level && obj_.timestamp == @timestamp && obj_.progname == @progname && obj_.record_id == @record_id && obj_.key == @key && obj_.value == @value && obj_.operation == @operation
|
306
306
|
end
|
307
|
-
|
307
|
+
|
308
308
|
def ==(obj_) # :nodoc:
|
309
309
|
eql?(obj_)
|
310
310
|
end
|
311
|
-
|
311
|
+
|
312
312
|
def hash # :nodoc:
|
313
313
|
type.hash ^ @level.hash ^ @timestamp.hash ^ @progname.hash ^ @record_id.hash ^ @key.hash ^ @value.hash ^ @operation.hash
|
314
314
|
end
|
315
|
-
|
316
|
-
|
315
|
+
|
316
|
+
|
317
317
|
end
|
318
|
-
|
319
|
-
|
318
|
+
|
319
|
+
|
320
320
|
end
|
321
|
-
|
322
|
-
|
321
|
+
|
322
|
+
|
323
323
|
end
|