Skip to content

Commit

Permalink
adjust cloud logs
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Feb 11, 2024
1 parent ff74574 commit 95f734e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,26 @@
config.active_record.dump_schema_after_migration = false

config.lograge.enabled = true
config.lograge.formatter = Lograge::Formatters::Json.new
config.lograge.base_controller_class = ['ActionController::API', 'ActionController::Base']

config.lograge.custom_payload do |controller|
{
fwd: controller.request.ip
}
if ENV['MULTITENANT'] == 'true'
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }

config.lograge.custom_payload do |controller|
{
fwd: controller.request.ip.to_s[/\A\d+\.(.*)/, 1],
params: controller.request.params&.slice(:id),
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.ip
}
end
end
end

0 comments on commit 95f734e

Please sign in to comment.