diff options
author | Matt Wrock <matt@mattwrock.com> | 2016-08-12 11:35:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-12 11:35:23 -0700 |
commit | 33bb7d1e6df113c9835ca608b008c4a31884188a (patch) | |
tree | 245a5905ed802d44e7c4748c3d3b6a5dc3b7acbf | |
parent | 44b302fa7f3e503d68eb4f458846f679900aab2f (diff) | |
parent | 8ea1c3912e7a2c5b323d0b79491b393bfdefb205 (diff) | |
download | mixlib-log-33bb7d1e6df113c9835ca608b008c4a31884188a.tar.gz |
Merge pull request #18 from chef/tm/configured_app
Allow applications to query if they've got loggers
-rwxr-xr-x | Gemfile | 1 | ||||
-rw-r--r-- | lib/mixlib/log.rb | 7 | ||||
-rw-r--r-- | spec/mixlib/log_spec.rb | 5 |
3 files changed, 13 insertions, 0 deletions
@@ -5,4 +5,5 @@ gemspec group :development do gem "rdoc" gem "bundler" + gem "rack", "< 2.0" end diff --git a/lib/mixlib/log.rb b/lib/mixlib/log.rb index 5ec1ba0..7152a90 100644 --- a/lib/mixlib/log.rb +++ b/lib/mixlib/log.rb @@ -66,6 +66,7 @@ module Mixlib "You gave: #{other.inspect}" raise ArgumentError, msg end + @configured = true end # Use Mixlib::Log.init when you want to set up the logger manually. Arguments to this method @@ -80,9 +81,15 @@ module Mixlib @logger = logger_for(*opts) @logger.formatter = Mixlib::Log::Formatter.new() if @logger.respond_to?(:formatter=) @logger.level = Logger::WARN + @configured = true @logger end + # Let the application query if logging objects have been set up + def configured? + @configured + end + # Sets the level for the Logger object by symbol. Valid arguments are: # # :debug diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb index 1eceff1..d780b0d 100644 --- a/spec/mixlib/log_spec.rb +++ b/spec/mixlib/log_spec.rb @@ -79,6 +79,11 @@ describe Mixlib::Log do expect(second_logdev.string).to match(/SECOND/) end + it "knows that it's been configured" do + Logit.init + expect(Logit.configured?).to be true + end + it "should set the log level using the binding form, with :debug, :info, :warn, :error, or :fatal" do levels = { :debug => Logger::DEBUG, |