Created
March 9, 2017 10:07
-
-
Save oriolgual/c06545662c11ffe346ddb028f77d98a9 to your computer and use it in GitHub Desktop.
Example LogRage & Rails configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def append_info_to_payload(payload) | |
super | |
payload[:remote_ip] = request.remote_ip | |
payload[:user_id] = current_user.try(:id) | |
payload[:organization_id] = current_organization.try(:id) | |
payload[:app] = current_organization.name | |
payload[:referer] = request.referer.to_s | |
payload[:request_id] = request.uuid | |
payload[:user_agent] = request.user_agent | |
payload[:xhr] = request.xhr? ? 'true' : 'false' | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/production.rb | |
config.lograge.enabled = true | |
config.lograge.formatter = Lograge::Formatters::Json.new | |
config.lograge.custom_options = lambda do |event| | |
{ | |
remote_ip: event.payload[:remote_ip], | |
params: event.payload[:params].except('controller', 'action', 'format', 'utf8'), | |
user_id: event.payload[:user_id], | |
organization_id: event.payload[:organization_id], | |
referer: event.payload[:referer], | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!