spec/timber/cli/installers/rails_spec.rb in timber-2.4.0 vs spec/timber/cli/installers/rails_spec.rb in timber-2.5.0
- old
+ new
@@ -93,16 +93,21 @@
exactly(1).times.
and_return(:send)
expected_code = <<-CODE
# Install the Timber.io logger
- send_logs_to_timber = true # <---- Set to false to stop sending development logs to Timber.io.
- # But do not remove the logger code below! The log_device should
- # be set to STDOUT if you want to disable sending logs.
+ # ----------------------------
+ # Remove the `http_device` to stop sending development logs to Timber.
+ # Be sure to keep the `file_device` or replace it with `STDOUT`.
+ http_device = Timber::LogDevices::HTTP.new('#{app.api_key}')
+ file_device = File.open("\#{Rails.root}/log/development.log", "a")
+ file_device.binmode
+ log_devices = [http_device, file_device]
- log_device = send_logs_to_timber ? Timber::LogDevices::HTTP.new('#{app.api_key}') : STDOUT
- logger = Timber::Logger.new(log_device)
+ # Do not modify below this line. It's important to keep the `Timber::Logger`
+ # because it provides an API for logging structured data and capturing context.
+ logger = Timber::Logger.new(*log_devices)
logger.level = config.log_level
config.logger = #{logger_code}
CODE
expect(installer).to receive(:install_logger).
@@ -312,10 +317,13 @@
describe ".install_nil" do
it "should pass the proper code" do
env_file_path = "config/environments/development.rb"
expected_code = <<-CODE
- # Install the Timber.io logger, but do not send logs.
+ # Install the Timber.io logger
+ # ----------------------------
+ # `nil` is passed to disable logging. It's important to keep the `Timber::Logger`
+ # because it provides an API for logging structured data and capturing context.
logger = Timber::Logger.new(nil)
logger.level = config.log_level
config.logger = #{logger_code}
CODE