Logging Unpermitted Parameters
Found out Unpermitted Parameters has instrumentation. So we can hijack it
*config/initializer/unpermittted.rb
logger = Logger.new(Rails.root.join('log', 'unpermitted.log'))
ActiveSupport::Notifications.subscribe 'unpermitted_parameters.action_controller' do |name, start, finish, id, payload|
msg = "Unpermitted_parameters: #{payload[:keys].map { |k| ":#{k}" }.join(', ')}"
puts Rainbow(msg).red.underline
logger.debug(msg)
end
And now I have STDOUT and logs full of debug with no context whatsoever but hey, thats’s in Rails 7
Robs-MacBook-Pro:sard rl$ tail -f log/unpermitted.log
# Logfile created on 2021-07-23 16:37:05 +0100 by logger.rb/66358
D, [2021-07-23T16:37:34.610337 #27379] DEBUG -- : Unpermitted_parameters: :id