diff --git a/lib/console/filter.rb b/lib/console/filter.rb index e6e3566..5fb240b 100644 --- a/lib/console/filter.rb +++ b/lib/console/filter.rb @@ -37,6 +37,8 @@ def self.[] **levels if self.enabled?(subject, level) @output.call(subject, *arguments, severity: name, **@options, **options, &block) end + + return nil end define_immutable_method("#{name}!") do @@ -150,6 +152,8 @@ def call(subject, *arguments, **options, &block) if self.enabled?(subject, level) @output.call(subject, *arguments, **options, &block) end + + return nil end end end diff --git a/test/console/filter.rb b/test/console/filter.rb index f1db614..ef8ea5a 100644 --- a/test/console/filter.rb +++ b/test/console/filter.rb @@ -66,29 +66,52 @@ def before end end + with "#info" do + it "ignores messages below the level" do + logger.level = Console::Logger::INFO + + result = logger.debug(MySubject, "Hello World") + + expect(output).to be(:empty?) + expect(result).to be_nil + end + + it "logs messages at the level" do + logger.level = Console::Logger::INFO + + result = logger.info(MySubject, "Hello World", severity: :info) + + expect(output).to be(:include?, "Hello World") + expect(result).to be_nil + end + end + with "#call" do it "ignores messages below the level" do logger.level = Console::Logger::INFO - logger.call(MySubject, "Hello World", severity: :debug) + result = logger.call(MySubject, "Hello World", severity: :debug) expect(output).to be(:empty?) + expect(result).to be_nil end it "logs messages at the level" do logger.level = Console::Logger::INFO - logger.call(MySubject, "Hello World", severity: :info) + result = logger.call(MySubject, "Hello World", severity: :info) expect(output).to be(:include?, "Hello World") + expect(result).to be_nil end it "logs messages above the level" do logger.level = Console::Logger::INFO - logger.call(MySubject, "Hello World", severity: :warn) + result = logger.call(MySubject, "Hello World", severity: :warn) expect(output).to be(:include?, "Hello World") + expect(result).to be_nil end end end