Skip to content

Commit af3e2d5

Browse files
committed
Make Grim::NullLogger act like Logger but not log anything
1 parent a3d0916 commit af3e2d5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/grim/null_logger.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
require "logger"
2+
13
module Grim
2-
class NullLogger
4+
class NullLogger < ::Logger
5+
def initialize(*args)
6+
end
7+
8+
def add(*args, &block)
9+
end
310
end
411
end

spec/lib/grim/null_logger_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'spec_helper'
2+
require "stringio"
3+
4+
describe Grim::NullLogger do
5+
it "acts like Logger but doesn't log anything" do
6+
io = StringIO.new
7+
logger = Grim::NullLogger.new(io)
8+
logger.debug "hello world"
9+
expect(io.string).to eq("")
10+
end
11+
end

0 commit comments

Comments
 (0)