Commit 65d46c9
Changed files (4)
spec
unit
lib/nasty/log.rb
@@ -8,7 +8,9 @@ module Nasty
end
def for(target)
- @@log_factory || ConsoleLogFactory.new
+ unless class_variable_defined? :@@log_factory
+ @@log_factory = ConsoleLogFactory.new
+ end
@@log_factory.create_for(target)
end
end
@@ -24,4 +26,10 @@ module Nasty
@logger
end
end
+
+ module Logging
+ def logger
+ Nasty::Log.for(self)
+ end
+ end
end
lib/nasty/object.rb
@@ -0,0 +1,3 @@
+class Object
+ include Nasty::Logging
+end
lib/nasty.rb
@@ -3,6 +3,7 @@ require "nasty/command"
require "nasty/composite_command"
require "nasty/kernel"
require "nasty/log"
+require "nasty/object"
require "nasty/lambda_behaviours"
require "nasty/version"
spec/unit/log_spec.rb
@@ -28,5 +28,11 @@ module Nasty
logger.should have_received(:debug).with("hi there")
end
end
+
+ context "logger" do
+ it "should be able to call the logger from anywhere" do
+ logger.debug("blah")
+ end
+ end
end
end