loggability 0.2.0 → 0.2.1

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.
data.tar.gz.sig CHANGED
Binary file
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == v0.2.1 [2012-05-10] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Bugfix for configuration via a Configurability::Config object.
4
+
5
+
1
6
  == v0.2.0 [2012-05-10] Michael Granger <ged@FaerieMUD.org>
2
7
 
3
8
  Add Configurability support.
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.0'
12
+ VERSION = '0.2.1'
13
13
 
14
14
  # VCS revision
15
- REVISION = %q$Revision: 4c9840dcb9fd $
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
- :defaults => {
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 = config.delete( :__default__ ) || config.delete( '__default__' )
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
- config.each do |key, logspec|
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
@@ -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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loggability
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
Binary file