Skip to content

Commit

Permalink
clean log
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Aug 19, 2024
1 parent 7a6f901 commit a0a0fdd
Showing 1 changed file with 27 additions and 37 deletions.
64 changes: 27 additions & 37 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,42 +126,32 @@
config.lograge.enabled = true
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']

if ENV['MULTITENANT'] == 'true'
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }

config.lograge.custom_payload do |controller|
params =
begin
controller.request.try(:params) || {}
rescue StandardError
{}
end

{
fwd: controller.request.remote_ip,
params: {
id: params[:id],
template_id: params[:template_id],
submission_id: params[:submission_id],
submitter_id: params[:submitter_id],
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
slug: (params[:slug] ||
params[:submitter_slug] ||
params[:submission_slug] ||
params[:submit_form_slug] ||
params[:template_slug]).to_s.last(5)
}.compact_blank,
host: controller.request.host,
uid: controller.instance_variable_get(:@current_user).try(:id)
}
end
else
config.lograge.formatter = Lograge::Formatters::Json.new

config.lograge.custom_payload do |controller|
{
fwd: controller.request.remote_ip
}
end
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }

config.lograge.custom_payload do |controller|
params =
begin
controller.request.try(:params) || {}
rescue StandardError
{}
end

{
fwd: controller.request.remote_ip,
params: {
id: params[:id],
template_id: params[:template_id],
submission_id: params[:submission_id],
submitter_id: params[:submitter_id],
sig: (params[:signed_uuid] || params[:signed_id]).to_s.split('--').first,
slug: (params[:slug] ||
params[:submitter_slug] ||
params[:submission_slug] ||
params[:submit_form_slug] ||
params[:template_slug]).to_s.first(5)
}.compact_blank,
host: controller.request.host,
uid: controller.instance_variable_get(:@current_user).try(:id)
}
end
end

0 comments on commit a0a0fdd

Please sign in to comment.