Permalink
Browse files

Merge pull request #57 from mnoble/honor_verbose_when_logging

Honor Barista#verbose when determining to log debug messages
  • Loading branch information...
2 parents 824ea73 + 0a043ab commit b306843acbae2ca41f587b423977b867dae3a5b4 @Sutto committed Mar 11, 2012
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/barista.rb
  2. +13 −0 spec/barista_spec.rb
View
2 lib/barista.rb
@@ -225,7 +225,7 @@ def output_path_for(file)
end
def debug(message)
- logger.debug "[Barista] #{message}" if logger
+ logger.debug "[Barista] #{message}" if logger && verbose?
end
def setup_defaults
View
13 spec/barista_spec.rb
@@ -62,6 +62,19 @@
Barista::compile_all!
File.exist?(File.join(@public_path, "alert.js")).should be_true
end
+ it "logs when verbose is true" do
+ log = StringIO.new
+ Barista.logger = Logger.new(log)
+ Barista.compile_all!
+ log.string.should =~ /\[Barista\].+/
+ end
+ it "does not log when verbose is false" do
+ log = StringIO.new
+ Barista.logger = Logger.new(log)
+ Barista.verbose = false
+ Barista.compile_all!
+ log.string.should be_empty
+ end
end
end

0 comments on commit b306843

Please sign in to comment.