summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlle Jonsson <olle.jonsson@gmail.com>2017-11-21 16:41:01 +0100
committerThom May <thom@chef.io>2018-02-28 14:36:20 +0000
commit7be3c2e2f1b2bb85157cc3124fe6adb90197c0d1 (patch)
tree54745914a48b6a6536443a695ffc3d39c56e24ec
parentcf0d1b987dc8ee8bc64e6b2b97ad6bd53d1c2332 (diff)
downloadmixlib-log-7be3c2e2f1b2bb85157cc3124fe6adb90197c0d1.tar.gz
Logging method return nil
- Fixes #21 Signed-off-by: Olle Jonsson <olle.jonsson@gmail.com>
-rw-r--r--lib/mixlib/log/logging.rb1
-rw-r--r--spec/mixlib/log_spec.rb13
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/mixlib/log/logging.rb b/lib/mixlib/log/logging.rb
index 537e1de..626237a 100644
--- a/lib/mixlib/log/logging.rb
+++ b/lib/mixlib/log/logging.rb
@@ -45,6 +45,7 @@ module Mixlib
level = LEVELS[method_name]
define_method(method_name) do |msg = nil, data: {}, &block|
pass(level, msg, data: data, &block)
+ nil
end
end
diff --git a/spec/mixlib/log_spec.rb b/spec/mixlib/log_spec.rb
index 137b557..5798a90 100644
--- a/spec/mixlib/log_spec.rb
+++ b/spec/mixlib/log_spec.rb
@@ -200,4 +200,17 @@ RSpec.describe Mixlib::Log do
expect(opened_files_count_after).to eq(opened_files_count_before + 1)
end
+ it "should return nil from its logging methods" do
+ expect(Logger).to receive(:new).with(STDOUT) { double("a-quiet-logger").as_null_object }
+ Logit.init
+
+ aggregate_failures "returns nil from logging method" do
+ expect(Logit.trace("hello")).to be_nil
+ expect(Logit.debug("hello")).to be_nil
+ expect(Logit.info("hello")).to be_nil
+ expect(Logit.warn("hello")).to be_nil
+ expect(Logit.error("hello")).to be_nil
+ expect(Logit.fatal("hello")).to be_nil
+ end
+ end
end