Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: ged/loggability
base: 351d7169e6
...
head fork: ged/loggability
compare: 8d49bba42b
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
2  .hgsigs
@@ -1,3 +1,5 @@
7eb43f3b1e1ec5dc279e635e0fc1f40953c2ae79 0 iEYEABECAAYFAk+mLaEACgkQ+zlz4UKpE6Q3pwCgjeRAfbi5rasU/ObIDME7JBHn5yQAoNdX+ZcEua8p75oVQcqk/BQbYjZd
1099204b229fe733ff6132d30e9a2d88ee500969 0 iEYEABECAAYFAk+oHwsACgkQ+zlz4UKpE6TAxgCg1YuvDwqqaQxoiidaH9ALBmFdFw0An0T7aMHIbxHdd4cx0MYozwSmDNs8
ea1633c450bea60098fcca8bd1f2267ea712d2fc 0 iEYEABECAAYFAk+poD8ACgkQ+zlz4UKpE6RgYQCgycWRlmqPFoMvM0gSm1CyVyLjedUAnir4Qm1ptMRfBTxKN7DOIyBc+qfn
+4c9840dcb9fd73d09f53c0de9ab42e02c61bc5c1 0 iEYEABECAAYFAk+sd6sACgkQ+zlz4UKpE6QzkwCfWvDrx4f0PCHRK8Ej/VJPoPvvGUAAnAiSdmk09toja3lsegnNXj+pTaKk
+3d9dced14889d1557396f74fa608c309c9836bf6 0 iEYEABECAAYFAk+snk4ACgkQ+zlz4UKpE6RpkACg9swkcE+giCafWlg3ZDJ+ruAGjQ0Anj2DizIYm0LLcCNMS2N22PHmy5Ye
View
2  .hgtags
@@ -1,3 +1,5 @@
6dc36a56ff79d3020fc8a335e7b975d053ee4f39 v0.0.1
9a502152869e732ca157ffec92d668805aa00d5c v0.0.2
929216c0ffee72b6f4c4605a1739eabc708c708a v0.1.0
+aa672f2fa207750d60d1a90a87989a7ceffa09fb v0.2.0
+cd911ef44cf02a584ad579105cbcbd28ed1f3045 v0.2.1
View
5 History.rdoc
@@ -1,3 +1,8 @@
+== v0.2.1 [2012-05-10] Michael Granger <ged@FaerieMUD.org>
+
+Bugfix for configuration via a Configurability::Config object.
+
+
== v0.2.0 [2012-05-10] Michael Granger <ged@FaerieMUD.org>
Add Configurability support.
View
13 lib/loggability.rb
@@ -9,7 +9,7 @@
module Loggability
# Package version constant
- VERSION = '0.2.0'
+ VERSION = '0.2.1'
# VCS revision
REVISION = %q$Revision$
@@ -22,11 +22,7 @@ module Loggability
# Configuration defaults
CONFIG_DEFAULTS = {
- :defaults => {
- :severity => 'warn',
- :formatter => 'default',
- :output => 'STDERR',
- },
+ :__default__ => 'warn STDERR',
}
# Regexp for parsing logspec lines in the config
@@ -293,9 +289,10 @@ def log_to( loghost )
def self::configure( config=nil )
if config
self.log.debug "Configuring Loggability with custom config."
+ confighash = config.to_hash
# Set up all loggers with defaults first
- if defaultspec = config.delete( :__default__ ) || config.delete( '__default__' )
+ if defaultspec = confighash.delete( :__default__ ) || confighash.delete( '__default__' )
level, format, target = self.parse_config_spec( defaultspec )
Loggability.level = level if level
Loggability.format_as( format ) if format
@@ -303,7 +300,7 @@ def self::configure( config=nil )
end
# Then let individual configs override.
- config.each do |key, logspec|
+ confighash.each do |key, logspec|
unless Loggability.log_host?( key )
self.log.debug " no such log host %p; skipping" % [ key ]
next
View
22 spec/loggability_spec.rb
@@ -146,6 +146,28 @@
Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
end
+ it "can configure loghosts with a Configurability::Config object" do
+ class1 = Class.new { extend Loggability; log_as :class1 }
+ class2 = Class.new { extend Loggability; log_as :class2 }
+
+ configsource = (<<-"END_CONFIG").gsub( /^\t{3}/, '' )
+ ---
+ logging:
+ class1: debug (html)
+ class2: error spec-error.log
+
+ END_CONFIG
+
+ config = Configurability::Config.new( configsource )
+ config.install
+
+ Loggability[ class1 ].level.should == :debug
+ Loggability[ class1 ].formatter.should be_a( Loggability::Formatter::HTML )
+ Loggability[ class2 ].level.should == :error
+ Loggability[ class2 ].logdev.dev.should be_a( File )
+ Loggability[ class2 ].logdev.dev.path.should == 'spec-error.log'
+ end
+
it "can configure all loghosts with a config key of __default__" do
Loggability.configure( '__default__' => 'debug STDERR (html)' )

No commit comments for this range

Something went wrong with that request. Please try again.