Skip to content

Commit

Permalink
Remove [Listen warning] prefix from warning message
Browse files Browse the repository at this point in the history
Since Listen.logger.warn formats the error message with a `WARN -- : #{msg}`
we don't need the [Listen warning] part as it is redundant
  • Loading branch information
AlexB52 committed Nov 29, 2023
1 parent bd460ab commit e7eebdc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "listen"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.

# (If you use this, don't forget to add pry to your Gemfile!)
# require "pry"
# Pry.start

require "irb"
IRB.start(__FILE__)
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)
Listen.logger.warn "[Listen warning]:\n #{msg}" if msg
Listen.logger.warn(msg) if msg
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/listen/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

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

Expand All @@ -59,7 +59,7 @@
end

it 'warns polling fallback with custom message if set' do
expected_msg = "[Listen warning]:\n custom fallback message"
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)
Expand Down

0 comments on commit e7eebdc

Please sign in to comment.