Sha256: f11825982196162516f7773e9614b4bd1a09e9e1058e2cb381c9350e9c1d9603

Contents?: true

Size: 452 Bytes

Versions: 2

Compression:

Stored size: 452 Bytes

Contents

# frozen_string_literal: true

require "logger"

module SilentPing
  class Logger < ::Rails::Rack::Logger
    PATH = "/ping"
    KEY = "PRESERVE_LEVEL"

    def call(env)
      return super(env) unless env["PATH_INFO"] == PATH

      begin
        env[KEY] = ::Rails.logger.level
        ::Rails.logger.level = ::Logger::DEBUG
        @app.call(env)
      ensure
        ::Rails.logger.level = env[KEY] unless env[KEY].nil?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
silent_ping-0.1.2 lib/silent_ping/logger.rb
silent_ping-0.1.0 lib/silent_ping/logger.rb