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

Replace Kernel warnings with Listen.logger #574

Closed
wants to merge 2 commits into from
Closed
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 lib/listen/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _usable_adapter_class

def _warn_polling_fallback(options)
msg = options.fetch(:polling_fallback_message, POLLING_FALLBACK_MESSAGE)
Kernel.warn "[Listen warning]:\n #{msg}" if msg
Listen.logger.warn(msg) if msg
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/bsd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.usable?
require 'find'
true
rescue LoadError
Kernel.warn BUNDLER_DECLARE_GEM
Listen.logger.warn BUNDLER_DECLARE_GEM
false
end

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/darwin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def self.usable?
require 'rb-fsevent'
fsevent_version = Gem::Version.new(FSEvent::VERSION)
return true if fsevent_version <= Gem::Version.new('0.9.4')
Kernel.warn INCOMPATIBLE_GEM_VERSION
Listen.logger.warn INCOMPATIBLE_GEM_VERSION
false
end

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/adapter/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.usable?
Listen.logger.debug format('wdm - load failed: %s:%s', $ERROR_INFO,
$ERROR_POSITION * "\n")

Kernel.warn BUNDLER_DECLARE_GEM
Listen.logger.warn BUNDLER_DECLARE_GEM
false
end

Expand Down
2 changes: 1 addition & 1 deletion lib/listen/record/symlink_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def verify_unwatched!(entry)
private

def _fail(symlinked, real_path)
warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
Listen.logger.warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks'
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/listen/adapter/darwin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
context 'with rb-fsevent > 0.9.4' do
before { stub_const('FSEvent::VERSION', '0.9.6') }
it 'shows a warning and should not be usable' do
expect(Kernel).to receive(:warn)
expect(Listen.logger).to receive(:warn)
expect(subject).to_not be_usable
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/listen/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end

context 'no usable adapters' do
before { allow(Kernel).to receive(:warn) }
before { allow(Listen.logger).to receive(:warn) }

it 'returns Polling adapter' do
klass = Listen::Adapter.select(force_polling: true)
Expand All @@ -49,18 +49,18 @@

it 'warns polling fallback with default message' do
msg = described_class::POLLING_FALLBACK_MESSAGE
expect(Kernel).to receive(:warn).with("[Listen warning]:\n #{msg}")
expect(Listen.logger).to receive(:warn).with(msg)
Listen::Adapter.select
end

it "doesn't warn if polling_fallback_message is false" do
expect(Kernel).to_not receive(:warn)
expect(Listen.logger).to_not receive(:warn)
Listen::Adapter.select(polling_fallback_message: false)
end

it 'warns polling fallback with custom message if set' do
expected_msg = "[Listen warning]:\n custom fallback message"
expect(Kernel).to receive(:warn).with(expected_msg)
expected_msg = "custom fallback message"
expect(Listen.logger).to receive(:warn).with(expected_msg)
msg = 'custom fallback message'
Listen::Adapter.select(polling_fallback_message: msg)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/listen/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def record_tree(record)
end

it 'shows a warning' do
expect_any_instance_of(Listen::Record::SymlinkDetector).to receive(:warn).
expect(Listen.logger).to receive(:warn).
with(/directory is already being watched/)

record.build
Expand Down