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/lib/sawmill/level.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Sawmill level class
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,37 +35,37 @@
35
35
 
36
36
 
37
37
  module Sawmill
38
-
39
-
38
+
39
+
40
40
  # Level objects represent logging levels, sometimes known as severities.
41
- #
41
+ #
42
42
  # A level object has a name and a numeric value. The name controls how the
43
43
  # level is represented in a logfile. The value indicates its severity rank
44
44
  # compared to other levels.
45
- #
45
+ #
46
46
  # Levels are organized into groups. Levels are comparable with one another
47
47
  # if they are part of the same group.
48
-
48
+
49
49
  class Level
50
50
 
51
-
51
+
52
52
  def initialize(group_, name_, value_) # :nodoc:
53
53
  @group = group_
54
54
  @name = name_
55
55
  @value = value_
56
56
  end
57
-
58
-
57
+
58
+
59
59
  # The LevelGroup of which this Level is a member
60
60
  attr_reader :group
61
-
61
+
62
62
  # The name of the level, as a string.
63
63
  attr_reader :name
64
-
64
+
65
65
  # The numeric value of the level.
66
66
  attr_reader :value
67
-
68
-
67
+
68
+
69
69
  # Compare this level with another level of the same group.
70
70
  def <=>(obj_)
71
71
  if obj_.respond_to?(:value) && obj_.respond_to?(:group)
@@ -74,40 +74,40 @@ module Sawmill
74
74
  nil
75
75
  end
76
76
  end
77
-
78
-
77
+
78
+
79
79
  # Returns the name.
80
80
  def to_s
81
81
  @name
82
82
  end
83
-
84
-
83
+
84
+
85
85
  def inspect # :nodoc:
86
86
  "#<#{self.class}:0x#{object_id.to_s(16)} name=#{@name.inspect} value=#{@value}>"
87
87
  end
88
-
89
-
88
+
89
+
90
90
  include ::Comparable
91
-
92
-
91
+
92
+
93
93
  end
94
-
95
-
94
+
95
+
96
96
  # A level group is a group of related levels that can be ordered and used
97
97
  # in a log. A given log is always associated with exactly one group, which
98
98
  # controls what levels are available for log entries.
99
- #
99
+ #
100
100
  # Normally, you will use Sawmill::STANDARD_LEVELS, which defines levels
101
101
  # corresponding to the ones available in the classic ruby logger class.
102
102
  # However, this class is available to define custom level hierarchies.
103
-
103
+
104
104
  class LevelGroup
105
-
106
-
105
+
106
+
107
107
  # Create a level group.
108
108
  # You must provide a block that calls methods of
109
109
  # Sawmill::LevelGroup::Builder to define the levels in the group.
110
-
110
+
111
111
  def initialize(&block_)
112
112
  @level_order = []
113
113
  @level_names = {}
@@ -115,58 +115,58 @@ module Sawmill
115
115
  @default = nil
116
116
  ::Blockenspiel.invoke(block_, Builder.new(self))
117
117
  end
118
-
119
-
118
+
119
+
120
120
  def inspect # :nodoc:
121
121
  "#<#{self.class}:0x#{object_id.to_s(16)} levels=[#{@level_order.map{|lvl_| lvl_.name.inspect}.join(',')}]>"
122
122
  end
123
-
124
-
123
+
124
+
125
125
  # Return the default level, the one used when no level is specified.
126
-
126
+
127
127
  def default
128
128
  @default ||= highest
129
129
  end
130
-
131
-
130
+
131
+
132
132
  # Return the lowest level in the group.
133
-
133
+
134
134
  def lowest
135
135
  @level_order.first
136
136
  end
137
-
138
-
137
+
138
+
139
139
  # Return the highest level in the group.
140
-
140
+
141
141
  def highest
142
142
  @level_order.last
143
143
  end
144
-
145
-
144
+
145
+
146
146
  # Return the length of the longest name in the group.
147
-
147
+
148
148
  def column_width
149
149
  @level_order.inject(0) do |width_, level_|
150
150
  w_ = level_.name.size
151
151
  w_ > width_ ? w_ : width_
152
152
  end
153
153
  end
154
-
155
-
154
+
155
+
156
156
  # Look up a level by a logger method name.
157
-
157
+
158
158
  def lookup_method(method_name_)
159
159
  @level_methods[method_name_.to_sym]
160
160
  end
161
-
162
-
161
+
162
+
163
163
  # Get a level in this group.
164
- #
164
+ #
165
165
  # You may pass either an integer value, a level name, a level object,
166
166
  # or nil. If you pass nil, the default level is returned. Otherwise,
167
167
  # the level corresponding to the given parameter is returned. If no
168
168
  # level in this group corresponds to the parameter, nil is returned.
169
-
169
+
170
170
  def get(name_)
171
171
  case name_
172
172
  when ::Integer
@@ -181,8 +181,8 @@ module Sawmill
181
181
  nil
182
182
  end
183
183
  end
184
-
185
-
184
+
185
+
186
186
  def _add(name_, opts_={}) # :nodoc:
187
187
  name_ = name_.to_sym
188
188
  default_ = opts_[:default]
@@ -211,26 +211,26 @@ module Sawmill
211
211
  end
212
212
  end
213
213
  end
214
-
215
-
214
+
215
+
216
216
  # You may call methods of this object in the block passed to
217
217
  # Sawmill::LevelGroup#new.
218
-
218
+
219
219
  class Builder
220
-
220
+
221
221
  include ::Blockenspiel::DSL
222
-
223
-
222
+
223
+
224
224
  def initialize(group_) # :nodoc:
225
225
  @group = group_
226
226
  end
227
-
228
-
227
+
228
+
229
229
  # Add a level to this group. The level is assigned the next value in
230
230
  # sequence, and the given name.
231
- #
231
+ #
232
232
  # You may also provide these options:
233
- #
233
+ #
234
234
  # [<tt>:default</tt>]
235
235
  # If set to true, this level is made the default.
236
236
  # [<tt>:methods</tt>]
@@ -238,19 +238,19 @@ module Sawmill
238
238
  # mapped to this level. You may then use those methods in the
239
239
  # Sawmill::Logger class as a shortcut for creating log messages with
240
240
  # this level.
241
-
241
+
242
242
  def add(name_, opts_={})
243
243
  @group._add(name_, opts_)
244
244
  end
245
-
246
-
245
+
246
+
247
247
  end
248
-
248
+
249
249
  end
250
-
251
-
250
+
251
+
252
252
  # A LevelGroup that corresponds to the classic ruby logger levels.
253
-
253
+
254
254
  STANDARD_LEVELS = LevelGroup.new do
255
255
  add(:DEBUG, :methods => 'debug')
256
256
  add(:INFO, :methods => 'info', :default => true)
@@ -259,6 +259,6 @@ module Sawmill
259
259
  add(:FATAL, :methods => 'fatal')
260
260
  add(:ANY, :methods => ['any', 'unknown'])
261
261
  end
262
-
263
-
262
+
263
+
264
264
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Sawmill logger class
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
  # A Rack middleware that starts and ends a log record.
41
41
  # Insert this in your Rack stack to wrap requests in a log record.
42
-
42
+
43
43
  class LogRecordMiddleware
44
-
45
-
44
+
45
+
46
46
  # Create a middleware object for Rack.
47
- #
47
+ #
48
48
  # If you do not provide a logger object, one will be generated for you
49
49
  # that simply logs to STDOUT.
50
- #
50
+ #
51
51
  # Recognized options include:
52
- #
52
+ #
53
53
  # [<tt>:request_id_key</tt>]
54
54
  # The name of a rack environment key where the request ID should be
55
55
  # stored. If not specified, defaults to "sawmill.request_id".
@@ -68,7 +68,7 @@ module Sawmill
68
68
  # [<tt>:post_logger</tt>]
69
69
  # A proc that is called at the end of the request, and passed the
70
70
  # logger and the rack environment. Optional.
71
-
71
+
72
72
  def initialize(app_, logger_=nil, opts_={})
73
73
  @app = app_
74
74
  @logger = logger_ || Logger.new(:progname => 'rack', :processor => Formatter.new(::STDOUT))
@@ -79,8 +79,8 @@ module Sawmill
79
79
  @pre_logger = opts_[:pre_logger]
80
80
  @post_logger = opts_[:post_logger]
81
81
  end
82
-
83
-
82
+
83
+
84
84
  def call(env_)
85
85
  env_[@request_id_key] = @logger.begin_record
86
86
  start_time_ = ::Time.now.utc
@@ -106,9 +106,9 @@ module Sawmill
106
106
  @logger.end_record
107
107
  end
108
108
  end
109
-
110
-
109
+
110
+
111
111
  end
112
-
113
-
112
+
113
+
114
114
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Sawmill logger class
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
@@ -38,19 +38,19 @@ require 'securerandom'
38
38
 
39
39
 
40
40
  module Sawmill
41
-
42
-
41
+
42
+
43
43
  # This is the Sawmill logger.
44
44
  # It duck-types most of the API of the logger class from the ruby
45
45
  # standard library, and adds capabilities specific to Sawmill.
46
-
46
+
47
47
  class Logger
48
-
49
-
48
+
49
+
50
50
  # Create a new logger.
51
- #
51
+ #
52
52
  # Supported options include:
53
- #
53
+ #
54
54
  # [<tt>:level_group</tt>]
55
55
  # Use a custom Sawmill::LevelGroup. Normally, you should leave this
56
56
  # set to the default, which is Sawmill::STANDARD_LEVELS.
@@ -76,7 +76,7 @@ module Sawmill
76
76
  # [<tt>:processor</tt>]
77
77
  # A processor for log entries generated by this logger.
78
78
  # If not specified, log entries are written out to STDOUT.
79
-
79
+
80
80
  def initialize(opts_={})
81
81
  @level_group = opts_[:level_group] || opts_[:levels] || STANDARD_LEVELS
82
82
  @level = @level_group.get(opts_[:level])
@@ -91,11 +91,11 @@ module Sawmill
91
91
  @processor = opts_[:processor] || Formatter.new(::STDOUT)
92
92
  @current_record_id = nil
93
93
  end
94
-
95
-
94
+
95
+
96
96
  # Emit a log message. This method has the same behavior as the
97
97
  # corresponding method in ruby's logger class.
98
-
98
+
99
99
  def add(level_, message_=nil, progname_=nil, &block_)
100
100
  level_obj_ = @level_group.get(level_)
101
101
  if level_obj_.nil?
@@ -124,58 +124,58 @@ module Sawmill
124
124
  true
125
125
  end
126
126
  alias_method :log, :add
127
-
128
-
127
+
128
+
129
129
  def to_s # :nodoc:
130
130
  inspect
131
131
  end
132
-
132
+
133
133
  def inspect # :nodoc:
134
134
  "#<#{self.class}:0x#{object_id.to_s(16)} progname=#{@progname.inspect} level=#{@level.name}>"
135
135
  end
136
-
137
-
136
+
137
+
138
138
  # Emits an "unknown" log entry. This is equivalent to the corresponding
139
139
  # method in ruby's logger class, which dumps the given string to the log
140
140
  # device without any formatting. Normally, you would not use this method
141
141
  # because it bypasses the log formatting and parsing capability.
142
-
142
+
143
143
  def <<(message_)
144
144
  add(@level_group.default, message_)
145
145
  end
146
-
147
-
146
+
147
+
148
148
  # Emits a begin_record log entry. This begins a new log record.
149
- #
149
+ #
150
150
  # If you pass a string ID, that ID is used as the record ID for the new
151
151
  # log record. If you leave it as nil, an ID is generated for you, using
152
152
  # the record id generator for this logger. In either case, the record ID
153
153
  # for the new record is returned.
154
- #
154
+ #
155
155
  # If you call this when a record is already open, the current record is
156
156
  # automatically closed before the new record is opened. That is, an
157
157
  # end_record is implicitly called in this case.
158
-
158
+
159
159
  def begin_record(id_=nil)
160
160
  end_record if @current_record_id
161
161
  @current_record_id = (id_ || @record_id_generator.call).to_s
162
162
  @processor.begin_record(Entry::BeginRecord.new(@level_group.highest, ::Time.now, @record_progname || @progname, @current_record_id))
163
163
  @current_record_id
164
164
  end
165
-
166
-
165
+
166
+
167
167
  # Returns the record ID for the currently open log record, or nil if
168
168
  # there is not a log record currently open.
169
-
169
+
170
170
  def current_record_id
171
171
  @current_record_id
172
172
  end
173
-
174
-
173
+
174
+
175
175
  # Ends the current log record by emitting an end_record log entry, if
176
176
  # a record is currently open. Returns the record ID of the ended log
177
177
  # record if one was open, or nil if no log record was open.
178
-
178
+
179
179
  def end_record
180
180
  if @current_record_id
181
181
  @processor.end_record(Entry::EndRecord.new(@level_group.highest, ::Time.now, @record_progname || @progname, @current_record_id))
@@ -186,17 +186,17 @@ module Sawmill
186
186
  nil
187
187
  end
188
188
  end
189
-
190
-
189
+
190
+
191
191
  # Emits an attribute log entry in the current record.
192
192
  # You must specify a key and a value as strings, and an operation.
193
193
  # The operation defaults to <tt>:set</tt> if not specified.
194
- #
194
+ #
195
195
  # If you specify a level, it will be used; otherwise the logger's
196
196
  # default attribute level is used.
197
197
  # Raises Errors::UnknownLevelError if you specify a level that doesn't
198
198
  # exist.
199
-
199
+
200
200
  def attribute(key_, value_, operation_=nil, level_=true, progname_=nil)
201
201
  if level_ == true
202
202
  level_obj_ = @attribute_level
@@ -210,73 +210,73 @@ module Sawmill
210
210
  @processor.attribute(Entry::Attribute.new(level_obj_, ::Time.now, progname_ || @record_progname || @progname, @current_record_id, key_, value_, operation_))
211
211
  true
212
212
  end
213
-
214
-
213
+
214
+
215
215
  # Emits a set-attribute log entry in the current record.
216
216
  # You must specify a key and a value as strings.
217
-
217
+
218
218
  def set_attribute(key_, value_)
219
219
  attribute(key_, value_, :set)
220
220
  end
221
-
222
-
221
+
222
+
223
223
  # Emits an append-attribute log entry in the current record.
224
224
  # You must specify a key and a value as strings.
225
-
225
+
226
226
  def append_attribute(key_, value_)
227
227
  attribute(key_, value_, :append)
228
228
  end
229
-
230
-
229
+
230
+
231
231
  # Close the logger by finishing the log entry processor to which it is
232
232
  # emitting log entries. Returns the value returned by the processor's
233
233
  # finish method.
234
-
234
+
235
235
  def close
236
236
  @processor.finish
237
237
  end
238
-
239
-
238
+
239
+
240
240
  # Get the current progname setting for this logger
241
-
241
+
242
242
  def progname
243
243
  @progname
244
244
  end
245
-
246
-
245
+
246
+
247
247
  # Set the current progname setting for this logger
248
-
248
+
249
249
  def progname=(value_)
250
250
  @progname = value_.to_s.gsub(/\s+/, '')
251
251
  end
252
-
253
-
252
+
253
+
254
254
  # Get the current record progname setting for this logger
255
-
255
+
256
256
  def record_progname
257
257
  @record_progname
258
258
  end
259
-
260
-
259
+
260
+
261
261
  # Set the current record progname setting for this logger
262
-
262
+
263
263
  def record_progname=(value_)
264
264
  @record_progname = value_.to_s.gsub(/\s+/, '')
265
265
  end
266
-
267
-
266
+
267
+
268
268
  # Get the current level setting for this logger as a Sawmill::Level.
269
-
269
+
270
270
  def level
271
271
  @level
272
272
  end
273
-
274
-
273
+
274
+
275
275
  # Set the current level setting for this logger.
276
276
  # You may specify the level as a string, a symbol, an integer, or a
277
277
  # Sawmill::Level. Ruby's logger constants such as ::Logger::INFO
278
278
  # will also work.
279
-
279
+
280
280
  def level=(value_)
281
281
  if value_.kind_of?(Level)
282
282
  @level = value_
@@ -288,24 +288,24 @@ module Sawmill
288
288
  @level = level_obj_
289
289
  end
290
290
  end
291
-
291
+
292
292
  alias_method :sev_threshold=, :level=
293
293
  alias_method :sev_threshold, :level
294
-
295
-
294
+
295
+
296
296
  # Get the current attribute level setting for this logger as a
297
297
  # Sawmill::Level.
298
-
298
+
299
299
  def attribute_level
300
300
  @attribute_level
301
301
  end
302
-
303
-
302
+
303
+
304
304
  # Set the current attribute level setting for this logger.
305
305
  # You may specify the level as a string, a symbol, an integer, or a
306
306
  # Sawmill::Level. Ruby's logger constants such as ::Logger::INFO
307
307
  # will also work.
308
-
308
+
309
309
  def attribute_level=(value_)
310
310
  if value_.kind_of?(Level)
311
311
  @attribute_level = value_
@@ -317,47 +317,47 @@ module Sawmill
317
317
  @attribute_level = level_obj_
318
318
  end
319
319
  end
320
-
321
-
320
+
321
+
322
322
  # Get the LevelGroup in use by this Logger. This setting cannot be
323
323
  # changed once the logger is constructed.
324
-
324
+
325
325
  def level_group
326
326
  @level_group
327
327
  end
328
-
329
-
328
+
329
+
330
330
  # Provide a block that generates and returns a unique record ID string.
331
331
  # This block will be called when begin_record is called without an
332
332
  # explicit ID provided. If you do not provide a block, Sawmill will use
333
333
  # a default generator which uses the variant 4 (random) UUID standard.
334
-
334
+
335
335
  def to_generate_record_id(&block_)
336
336
  @record_id_generator = block_ || Logger._get_default_record_id_generator
337
337
  end
338
-
339
-
338
+
339
+
340
340
  # You may call additional methods on the logger as shortcuts to log
341
341
  # messages at specific levels, or to query whether the logger is logging
342
342
  # to a given level. These methods match the corresponding methods in the
343
343
  # classic ruby logger object, except that they are configurable for
344
344
  # custom level schemes.
345
- #
345
+ #
346
346
  # For example, in the standard level scheme, the method "info" is
347
347
  # defined, so you may call:
348
- #
348
+ #
349
349
  # logger.info("MainApp") { "Received connection from #{ip}" }
350
350
  # # ...
351
351
  # logger.info "Waiting for input from user"
352
352
  # # ...
353
353
  # logger.info { "User typed #{input}" }
354
- #
354
+ #
355
355
  # You may also call:
356
- #
356
+ #
357
357
  # logger.info? # Returns true if INFO messages are accepted
358
- #
358
+ #
359
359
  # Methods available in the standard level scheme are as follows:
360
- #
360
+ #
361
361
  # * <tt>debug</tt>
362
362
  # * <tt>info</tt>
363
363
  # * <tt>warn</tt>
@@ -365,11 +365,11 @@ module Sawmill
365
365
  # * <tt>fatal</tt>
366
366
  # * <tt>unknown</tt>
367
367
  # * <tt>any</tt>
368
- #
368
+ #
369
369
  # The "unknown" and "any" methods both correspond to the +ANY+ level.
370
370
  # The latter is the preferred name under Sawmill. The former is for
371
371
  # backward compatibility with ruby's classic logger.
372
-
372
+
373
373
  def method_missing(method_, *args_, &block_)
374
374
  method_name_ = method_.to_s
375
375
  question_ = method_name_[-1..-1] == '?'
@@ -382,8 +382,8 @@ module Sawmill
382
382
  add(level_, nil, args_[0], &block_)
383
383
  end
384
384
  end
385
-
386
-
385
+
386
+
387
387
  def self._get_default_record_id_generator # :nodoc:
388
388
  @_default_generator ||= ::Proc.new do
389
389
  uuid_ = ::SecureRandom.hex(16)
@@ -396,9 +396,9 @@ module Sawmill
396
396
  uuid_
397
397
  end
398
398
  end
399
-
400
-
399
+
400
+
401
401
  end
402
-
403
-
402
+
403
+
404
404
  end