Sha256: 241f0336f0e499b25dfd03ec5b94d426744f3b6a791ed26f2c85aa0d4b82daf4

Contents?: true

Size: 564 Bytes

Versions: 52

Compression:

Stored size: 564 Bytes

Contents

module LogHelpers
  def capture_logs(&block)
    log = std_stream
    use_logger_with(log, &block)
    log_contents(log)
  end

  def use_logger_with(log)
    Appsignal.logger = test_logger(log)
    yield
    Appsignal.logger = nil
  end

  def test_logger(log)
    Logger.new(log).tap do |logger|
      logger.formatter =
        proc do |severity, _datetime, _progname, msg|
          # This format is used in the `contains_log` matcher.
          "[#{severity}] #{msg}\n"
        end
    end
  end

  def log_contents(log)
    log.rewind
    log.read
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
appsignal-2.10.2-java spec/support/helpers/log_helpers.rb
appsignal-2.10.2 spec/support/helpers/log_helpers.rb
appsignal-2.10.1-java spec/support/helpers/log_helpers.rb
appsignal-2.10.1 spec/support/helpers/log_helpers.rb
appsignal-2.10.0-java spec/support/helpers/log_helpers.rb
appsignal-2.10.0 spec/support/helpers/log_helpers.rb
appsignal-2.9.18 spec/support/helpers/log_helpers.rb
appsignal-2.9.18-java spec/support/helpers/log_helpers.rb
appsignal-2.9.18.beta.2-java spec/support/helpers/log_helpers.rb
appsignal-2.9.18.beta.2 spec/support/helpers/log_helpers.rb
appsignal-2.9.18.beta.1 spec/support/helpers/log_helpers.rb
appsignal-2.9.18.beta.1-java spec/support/helpers/log_helpers.rb
appsignal-2.9.17-java spec/support/helpers/log_helpers.rb
appsignal-2.9.17 spec/support/helpers/log_helpers.rb
appsignal-2.9.16-java spec/support/helpers/log_helpers.rb
appsignal-2.9.16 spec/support/helpers/log_helpers.rb
appsignal-2.9.15-java spec/support/helpers/log_helpers.rb
appsignal-2.9.15 spec/support/helpers/log_helpers.rb
appsignal-2.9.14-java spec/support/helpers/log_helpers.rb
appsignal-2.9.14 spec/support/helpers/log_helpers.rb