Skip to content

Instantly share code, notes, and snippets.

@ritikesh
Last active May 6, 2020 15:16
Show Gist options
  • Save ritikesh/87d47e23e5f12a4de84e4dd063606036 to your computer and use it in GitHub Desktop.
Save ritikesh/87d47e23e5f12a4de84e4dd063606036 to your computer and use it in GitHub Desktop.
blog gists
class Middleware::CustomLogging
def initialize(app)
@app = app
end
def call(env)
if debug_logging?
Rails.logger.level = Logger::DEBUG
end
@status, @headers, @response = @app.call(env)
ensure
Rails.logger.level = Logger::INFO if Rails.logger.debug?
end
private
def debug_logging?
MemoizeUntil.hour(:debug_logging) {
$redis.get(“DEBUG_LOGGING”)
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment