Last active
May 6, 2020 15:16
-
-
Save ritikesh/87d47e23e5f12a4de84e4dd063606036 to your computer and use it in GitHub Desktop.
blog gists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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