1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_controller/metal/logging.rb
George Claghorn 75a53297c7
Add ActionController::Base.log_at
Allow setting a different log level per request.
2019-09-24 13:47:34 -04:00

20 lines
536 B
Ruby

# frozen_string_literal: true
module ActionController
module Logging
extend ActiveSupport::Concern
module ClassMethods
# Set a different log level per request.
#
# # Use the debug log level if a particular cookie is set.
# class ApplicationController < ActionController::Base
# log_at :debug, if: -> { cookies[:debug] }
# end
#
def log_at(level, **options)
around_action ->(_, action) { logger.log_at(level, &action) }, **options
end
end
end
end