From 9b18ee4bba634bf239d6cb83e78e7167b2eca8d9 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 19 Jul 2018 08:23:59 +0800 Subject: [PATCH] Improve handling of file params in lograge. --- config/initializers/101-lograge.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rb index 650a046039d..f9013d51c29 100644 --- a/config/initializers/101-lograge.rb +++ b/config/initializers/101-lograge.rb @@ -46,7 +46,16 @@ if (Rails.env.production? && SiteSetting.logging_provider == 'lograge') || ENV[" exceptions = %w(controller action format id) params = event.payload[:params].except(*exceptions) - params[:files].map!(&:headers) if params[:files] + + if (file = params[:file]) && file.respond_to?(:headers) + param[:file] = file.headers + end + + if (files = params[:files]) + params[:files] = files.map do |file| + file.respond_to?(:headers) ? file.headers : file + end + end output = { params: params.to_query,