sawmill 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +5 -0
- data/lib/sawmill/interface.rb +3 -3
- data/lib/sawmill/logger.rb +24 -16
- data/lib/sawmill/rotater.rb +1 -1
- data/lib/sawmill/version.rb +1 -1
- metadata +2 -2
data/History.rdoc
CHANGED
data/lib/sawmill/interface.rb
CHANGED
@@ -94,7 +94,7 @@ module Sawmill
|
|
94
94
|
else
|
95
95
|
raise ::ArgumentError, "You must pass a file path or an IO object"
|
96
96
|
end
|
97
|
-
processor_ = EntryProcessor::Format.new(io_, opts_)
|
97
|
+
processor_ = EntryProcessor::Format.new(io_, opts_.dup)
|
98
98
|
Logger.new(opts_.merge(:processor => processor_))
|
99
99
|
end
|
100
100
|
|
@@ -171,7 +171,7 @@ module Sawmill
|
|
171
171
|
def shifting_logfile(filepath_, period_, max_size_, opts_={})
|
172
172
|
rotater_ = Rotater.new(Rotater::ShiftingLogFile, opts_.merge(:file_path => filepath_,
|
173
173
|
:max_file_size => max_size_, :shift_period => period_))
|
174
|
-
processor_ = EntryProcessor::Format.new(rotater_, opts_)
|
174
|
+
processor_ = EntryProcessor::Format.new(rotater_, opts_.dup)
|
175
175
|
Logger.new(opts_.merge(:processor => processor_))
|
176
176
|
end
|
177
177
|
|
@@ -242,7 +242,7 @@ module Sawmill
|
|
242
242
|
def date_based_logfile(filepath_, frequency_, opts_={})
|
243
243
|
rotater_ = Rotater.new(Rotater::DateBasedLogFile, opts_.merge(:path_prefix => filepath_,
|
244
244
|
:turnover_frequency => frequency_))
|
245
|
-
processor_ = EntryProcessor::Format.new(rotater_, opts_)
|
245
|
+
processor_ = EntryProcessor::Format.new(rotater_, opts_.dup)
|
246
246
|
Logger.new(opts_.merge(:processor => processor_))
|
247
247
|
end
|
248
248
|
|
data/lib/sawmill/logger.rb
CHANGED
@@ -54,7 +54,7 @@ module Sawmill
|
|
54
54
|
#
|
55
55
|
# Supported options include:
|
56
56
|
#
|
57
|
-
# <tt>:
|
57
|
+
# <tt>:level_group</tt>::
|
58
58
|
# Use a custom Sawmill::LevelGroup. Normally, you should leave this
|
59
59
|
# set to the default, which is Sawmill::STANDARD_LEVELS.
|
60
60
|
# <tt>:level</tt>::
|
@@ -81,12 +81,12 @@ module Sawmill
|
|
81
81
|
# If not specified, log entries are written out to STDOUT.
|
82
82
|
|
83
83
|
def initialize(opts_={})
|
84
|
-
@
|
85
|
-
@level = @
|
84
|
+
@level_group = opts_[:level_group] || opts_[:levels] || STANDARD_LEVELS
|
85
|
+
@level = @level_group.get(opts_[:level])
|
86
86
|
if opts_.include?(:attribute_level)
|
87
|
-
@attribute_level = @
|
87
|
+
@attribute_level = @level_group.get(opts_[:attribute_level])
|
88
88
|
else
|
89
|
-
@attribute_level = @
|
89
|
+
@attribute_level = @level_group.highest
|
90
90
|
end
|
91
91
|
@progname = opts_[:progname] || 'sawmill'
|
92
92
|
@record_progname = opts_[:record_progname]
|
@@ -100,7 +100,7 @@ module Sawmill
|
|
100
100
|
# corresponding method in ruby's logger class.
|
101
101
|
|
102
102
|
def add(level_, message_=nil, progname_=nil, &block_)
|
103
|
-
level_obj_ = @
|
103
|
+
level_obj_ = @level_group.get(level_)
|
104
104
|
if level_obj_.nil?
|
105
105
|
raise Errors::UnknownLevelError, level_
|
106
106
|
end
|
@@ -144,7 +144,7 @@ module Sawmill
|
|
144
144
|
# because it bypasses the log formatting and parsing capability.
|
145
145
|
|
146
146
|
def <<(message_)
|
147
|
-
add(@
|
147
|
+
add(@level_group.default, message_)
|
148
148
|
end
|
149
149
|
|
150
150
|
|
@@ -162,7 +162,7 @@ module Sawmill
|
|
162
162
|
def begin_record(id_=nil)
|
163
163
|
end_record if @current_record_id
|
164
164
|
@current_record_id = (id_ || @record_id_generator.call).to_s
|
165
|
-
@processor.begin_record(Entry::BeginRecord.new(@
|
165
|
+
@processor.begin_record(Entry::BeginRecord.new(@level_group.highest, ::Time.now, @record_progname || @progname, @current_record_id))
|
166
166
|
@current_record_id
|
167
167
|
end
|
168
168
|
|
@@ -181,7 +181,7 @@ module Sawmill
|
|
181
181
|
|
182
182
|
def end_record
|
183
183
|
if @current_record_id
|
184
|
-
@processor.end_record(Entry::EndRecord.new(@
|
184
|
+
@processor.end_record(Entry::EndRecord.new(@level_group.highest, ::Time.now, @record_progname || @progname, @current_record_id))
|
185
185
|
id_ = @current_record_id
|
186
186
|
@current_record_id = nil
|
187
187
|
id_
|
@@ -204,7 +204,7 @@ module Sawmill
|
|
204
204
|
if level_ == true
|
205
205
|
level_obj_ = @attribute_level
|
206
206
|
else
|
207
|
-
level_obj_ = @
|
207
|
+
level_obj_ = @level_group.get(level_)
|
208
208
|
if level_obj_.nil?
|
209
209
|
raise Errors::UnknownLevelError, level_
|
210
210
|
end
|
@@ -270,7 +270,7 @@ module Sawmill
|
|
270
270
|
if value_.kind_of?(Level)
|
271
271
|
@level = value_
|
272
272
|
else
|
273
|
-
level_obj_ = @
|
273
|
+
level_obj_ = @level_group.get(value_)
|
274
274
|
if level_obj_.nil?
|
275
275
|
raise Errors::UnknownLevelError, value_
|
276
276
|
end
|
@@ -282,6 +282,14 @@ module Sawmill
|
|
282
282
|
alias_method :sev_threshold, :level
|
283
283
|
|
284
284
|
|
285
|
+
# Get the LevelGroup in use by this Logger. This setting cannot be
|
286
|
+
# changed once the logger is constructed.
|
287
|
+
|
288
|
+
def level_group
|
289
|
+
@level_group
|
290
|
+
end
|
291
|
+
|
292
|
+
|
285
293
|
# Provide a block that generates and returns a unique record ID string.
|
286
294
|
# This block will be called when begin_record is called without an
|
287
295
|
# explicit ID provided. If you do not provide a block, Sawmill will use
|
@@ -329,7 +337,7 @@ module Sawmill
|
|
329
337
|
method_name_ = method_.to_s
|
330
338
|
question_ = method_name_[-1..-1] == '?'
|
331
339
|
method_name_ = method_name_[0..-2] if question_
|
332
|
-
level_ = @
|
340
|
+
level_ = @level_group.lookup_method(method_name_)
|
333
341
|
return super(method_, *args_, &block_) unless level_
|
334
342
|
if question_
|
335
343
|
level_ >= @level
|
@@ -342,20 +350,20 @@ module Sawmill
|
|
342
350
|
def self._get_default_record_id_generator # :nodoc:
|
343
351
|
unless @_default_generator
|
344
352
|
if defined?(::SecureRandom)
|
345
|
-
|
353
|
+
_random_hex32 = ::Proc.new do
|
346
354
|
::SecureRandom.hex(16)
|
347
355
|
end
|
348
356
|
elsif defined?(::ActiveSupport::SecureRandom)
|
349
|
-
|
357
|
+
_random_hex32 = ::Proc.new do
|
350
358
|
::ActiveSupport::SecureRandom.hex(16)
|
351
359
|
end
|
352
360
|
else
|
353
|
-
|
361
|
+
_random_hex32 = ::Proc.new do
|
354
362
|
::Kernel.rand(0x100000000000000000000000000000000).to_s(16).rjust(32, '0')
|
355
363
|
end
|
356
364
|
end
|
357
365
|
@_default_generator = ::Proc.new do
|
358
|
-
uuid_ = _random_hex32
|
366
|
+
uuid_ = _random_hex32.call
|
359
367
|
uuid_[12] = '4'
|
360
368
|
uuid_[16] = (uuid_[16,1].to_i(16)&3|8).to_s(16)
|
361
369
|
uuid_.insert(8, '-')
|
data/lib/sawmill/rotater.rb
CHANGED
data/lib/sawmill/version.rb
CHANGED
@@ -43,7 +43,7 @@ end
|
|
43
43
|
module Sawmill
|
44
44
|
|
45
45
|
# Current gem version, as a frozen string.
|
46
|
-
VERSION_STRING = '0.0.
|
46
|
+
VERSION_STRING = '0.0.9'.freeze
|
47
47
|
|
48
48
|
# Current gem version, as a Versionomy::Value if the versionomy library
|
49
49
|
# is available, or as a frozen string if not.
|
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.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-28 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|