Skip to content

Commit

Permalink
Exclude more params; skip common root requests
Browse files Browse the repository at this point in the history
  • Loading branch information
cavis committed Mar 19, 2024
1 parent 0fc5367 commit e10688e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,26 @@ def call(severity, time, progname, data)

config.lograge.enabled = true
config.lograge.custom_payload do |controller|
exclude = %w[controller action format id authenticity_token access_token id_token]
{
params: controller.request.params.except(*%w[controller action format id]),
params: controller.request.params.except(*exclude),
user_agent: controller.request.user_agent,
user_id: controller.try(:api_admin_token?) ? "admin-token" : controller.prx_auth_token&.user_id&.to_i,
user_ip: controller.request.ip
}
end

config.lograge.ignore_custom = lambda do |event|
if event.payload[:path] == "/" && event.payload[:status] == 302
true
elsif event.payload[:path] == "/api/v1"
true
end
end

config.lograge.formatter = Class.new do |fmt|
def fmt.call(data)
{msg: "Request", request: data.without(*%w[unpermitted_params])}
{msg: "Request", request: data.without(*%i[unpermitted_params])}
end
end

Expand Down

0 comments on commit e10688e

Please sign in to comment.