Permalink
Browse files

add a global logger

  • Loading branch information...
1 parent 9212b5e commit deefcfab976317ca4a4642d765e4abc3dccdd0fb @rubysolo rubysolo committed May 30, 2013
Showing with 15 additions and 1 deletion.
  1. +1 −1 lib/yell/repository.rb
  2. +14 −0 spec/yell/repository_spec.rb
View
@@ -38,7 +38,7 @@ def []=( name, logger )
# @raise [Yell::LoggerNotFound] Raised when repository does not have that key
# @return [Yell::Logger] The logger instance
def []( name )
- synchronize { instance.fetch(name) or raise Yell::LoggerNotFound.new(name) }
+ synchronize { instance.fetch(name) or instance.fetch(:global) or raise Yell::LoggerNotFound.new(name) }
end
# Get the list of all loggers in the repository
@@ -18,6 +18,20 @@
subject.should == logger
end
+ context "with a global logger" do
+ before do
+ @logger = Yell.new :stdout, :name => :global
+ end
+
+ it "should not raise with any name supplied" do
+ lambda { Yell::Repository[ String ] }.should_not raise_error
+ end
+
+ it "should return the global logger" do
+ Yell::Repository[ Numeric ].should == @logger
+ end
+ end
+
context "given a Class" do
before do
@logger = Yell.new :stdout, :name => "Numeric"

0 comments on commit deefcfa

Please sign in to comment.