Skip to content

Commit

Permalink
Merge pull request #49 from salemove/support_add
Browse files Browse the repository at this point in the history
Support logger.add
  • Loading branch information
urmastalimaa authored Mar 12, 2024
2 parents 188a14b + 985938b commit ed543be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
lenjador (2.2.2)
lenjador (2.3.0)
lru_redux
oj (~> 3.6)

Expand Down
2 changes: 1 addition & 1 deletion lenjador.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |gem|
gem.name = 'lenjador'
gem.version = '2.2.2'
gem.version = '2.3.0'
gem.authors = ['Salemove']
gem.email = ['[email protected]']
gem.description = "It's lenjadoric"
Expand Down
5 changes: 5 additions & 0 deletions lib/lenjador.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def initialize(adapter, level, preprocessors)
@preprocessors = preprocessors
end

def add(severity, *args, &block)
level = SEV_LABEL.index(severity.to_s)
log(level, *args, &block)
end

def debug(*args, &block)
log(Severity::DEBUG, *args, &block)
end
Expand Down
14 changes: 14 additions & 0 deletions spec/lenjador_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@
end
end

describe '#add' do
let(:adapter) { double }
let(:lenjador) { described_class.new(adapter, Lenjador::Severity::INFO, []) }

it 'logs with severity' do
expect(adapter).to receive(:log).with(described_class::Severity::INFO, message: 'info-msg').ordered
expect(adapter).to receive(:log).with(described_class::Severity::WARN, message: 'warn-msg').ordered

lenjador.add('debug', 'debug-msg')
lenjador.add('info', 'info-msg')
lenjador.add('warn', 'warn-msg')
end
end

context 'when preprocessor defined' do
let(:lenjador) { described_class.new(adapter, level, [preprocessor]) }
let(:adapter) { double }
Expand Down

0 comments on commit ed543be

Please sign in to comment.