Skip to content

Commit

Permalink
initialize logger base class
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Aug 26, 2024
1 parent 49210c8 commit 973d23b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 53 deletions.
24 changes: 3 additions & 21 deletions lib/rollbar/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ module Rollbar
class Logger < ::Logger
class Error < RuntimeError; end

class DatetimeFormatNotSupported < Error; end

class FormatterNotSupported < Error; end

def initialize
@level = ERROR
super(nil)

self.level = ERROR
end

def add(severity, message = nil, progname = nil)
Expand All @@ -39,22 +37,6 @@ def <<(message)
error(message)
end

def formatter=(_)
raise(FormatterNotSupported)
end

def formatter
raise(FormatterNotSupported)
end

def datetime_format=(_)
raise(DatetimeFormatNotSupported)
end

def datetime_format
raise(DatetimeFormatNotSupported)
end

# Returns a Rollbar::Notifier instance with the current global scope and
# with a logger writing to /dev/null so we don't have a infinite loop
# when Rollbar.configuration.logger is Rails.logger.
Expand Down
32 changes: 0 additions & 32 deletions spec/rollbar/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,6 @@
end
end

describe '#formatter=' do
it 'fails with FormatterNotSupported' do
expect do
subject.formatter = double
end.to raise_error(Rollbar::Logger::FormatterNotSupported)
end
end

describe '#formatter' do
it 'fails with FormatterNotSupported' do
expect do
subject.formatter
end.to raise_error(Rollbar::Logger::FormatterNotSupported)
end
end

describe '#datetime_format=' do
it 'fails with DatetimeFormatNotSupported' do
expect do
subject.datetime_format = double
end.to raise_error(Rollbar::Logger::DatetimeFormatNotSupported)
end
end

describe '#datetime_format' do
it 'fails with DatetimeFormatNotSupported' do
expect do
subject.datetime_format
end.to raise_error(Rollbar::Logger::DatetimeFormatNotSupported)
end
end

describe '#rollbar' do
it 'returns a Rollbar notifier with a logger pointing to /dev/null' do
notifier = subject.rollbar
Expand Down

0 comments on commit 973d23b

Please sign in to comment.