Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unknown severity levels #50

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.3.0)
lenjador (2.3.1)
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.3.0'
gem.version = '2.3.1'
gem.authors = ['Salemove']
gem.email = ['[email protected]']
gem.description = "It's lenjadoric"
Expand Down
3 changes: 1 addition & 2 deletions lib/lenjador.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def initialize(adapter, level, preprocessors)
end

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

def debug(*args, &block)
Expand Down
14 changes: 8 additions & 6 deletions spec/lenjador_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
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')
expect(adapter).to receive(:log).with(Logger::INFO, message: 'info-msg').ordered
expect(adapter).to receive(:log).with(Logger::WARN, message: 'warn-msg').ordered
expect(adapter).to receive(:log).with(Logger::UNKNOWN, message: 'unknown-msg').ordered

lenjador.add(Logger::DEBUG, 'debug-msg')
lenjador.add(Logger::INFO, 'info-msg')
lenjador.add(Logger::WARN, 'warn-msg')
lenjador.add(Logger::UNKNOWN, 'unknown-msg')
end
end

Expand Down
Loading