loggability 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.rdoc +5 -0
- data/lib/loggability.rb +6 -9
- data/spec/loggability_spec.rb +22 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/lib/loggability.rb
CHANGED
@@ -9,10 +9,10 @@ require 'date'
|
|
9
9
|
module Loggability
|
10
10
|
|
11
11
|
# Package version constant
|
12
|
-
VERSION = '0.2.
|
12
|
+
VERSION = '0.2.1'
|
13
13
|
|
14
14
|
# VCS revision
|
15
|
-
REVISION = %q$Revision:
|
15
|
+
REVISION = %q$Revision: 3d9dced14889 $
|
16
16
|
|
17
17
|
# The key for the global logger (Loggability's own logger)
|
18
18
|
GLOBAL_KEY = :__global__
|
@@ -22,11 +22,7 @@ module Loggability
|
|
22
22
|
|
23
23
|
# Configuration defaults
|
24
24
|
CONFIG_DEFAULTS = {
|
25
|
-
:
|
26
|
-
:severity => 'warn',
|
27
|
-
:formatter => 'default',
|
28
|
-
:output => 'STDERR',
|
29
|
-
},
|
25
|
+
:__default__ => 'warn STDERR',
|
30
26
|
}
|
31
27
|
|
32
28
|
# Regexp for parsing logspec lines in the config
|
@@ -293,9 +289,10 @@ module Loggability
|
|
293
289
|
def self::configure( config=nil )
|
294
290
|
if config
|
295
291
|
self.log.debug "Configuring Loggability with custom config."
|
292
|
+
confighash = config.to_hash
|
296
293
|
|
297
294
|
# Set up all loggers with defaults first
|
298
|
-
if defaultspec =
|
295
|
+
if defaultspec = confighash.delete( :__default__ ) || confighash.delete( '__default__' )
|
299
296
|
level, format, target = self.parse_config_spec( defaultspec )
|
300
297
|
Loggability.level = level if level
|
301
298
|
Loggability.format_as( format ) if format
|
@@ -303,7 +300,7 @@ module Loggability
|
|
303
300
|
end
|
304
301
|
|
305
302
|
# Then let individual configs override.
|
306
|
-
|
303
|
+
confighash.each do |key, logspec|
|
307
304
|
unless Loggability.log_host?( key )
|
308
305
|
self.log.debug " no such log host %p; skipping" % [ key ]
|
309
306
|
next
|
data/spec/loggability_spec.rb
CHANGED
@@ -146,6 +146,28 @@ describe Loggability do
|
|
146
146
|
Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
|
147
147
|
end
|
148
148
|
|
149
|
+
it "can configure loghosts with a Configurability::Config object" do
|
150
|
+
class1 = Class.new { extend Loggability; log_as :class1 }
|
151
|
+
class2 = Class.new { extend Loggability; log_as :class2 }
|
152
|
+
|
153
|
+
configsource = (<<-"END_CONFIG").gsub( /^\t{3}/, '' )
|
154
|
+
---
|
155
|
+
logging:
|
156
|
+
class1: debug (html)
|
157
|
+
class2: error spec-error.log
|
158
|
+
|
159
|
+
END_CONFIG
|
160
|
+
|
161
|
+
config = Configurability::Config.new( configsource )
|
162
|
+
config.install
|
163
|
+
|
164
|
+
Loggability[ class1 ].level.should == :debug
|
165
|
+
Loggability[ class1 ].formatter.should be_a( Loggability::Formatter::HTML )
|
166
|
+
Loggability[ class2 ].level.should == :error
|
167
|
+
Loggability[ class2 ].logdev.dev.should be_a( File )
|
168
|
+
Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
|
169
|
+
end
|
170
|
+
|
149
171
|
it "can configure all loghosts with a config key of __default__" do
|
150
172
|
Loggability.configure( '__default__' => 'debug STDERR (html)' )
|
151
173
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|