Commit 190fae5f authored by Sean McGivern's avatar Sean McGivern

Merge branch 'sh-augment-lograge-output' into 'master'

Add remote IP, user ID and username to JSON lograge output

See merge request !13147
parents 3f1b7b88 96c4a15e
...@@ -70,6 +70,16 @@ class ApplicationController < ActionController::Base ...@@ -70,6 +70,16 @@ class ApplicationController < ActionController::Base
protected protected
def append_info_to_payload(payload)
super
payload[:remote_ip] = request.remote_ip
if current_user.present?
payload[:user_id] = current_user.id
payload[:username] = current_user.username
end
end
# This filter handles both private tokens and personal access tokens # This filter handles both private tokens and personal access tokens
def authenticate_user_from_private_token! def authenticate_user_from_private_token!
token = params[:private_token].presence || request.headers['PRIVATE-TOKEN'].presence token = params[:private_token].presence || request.headers['PRIVATE-TOKEN'].presence
......
...@@ -14,7 +14,10 @@ unless Sidekiq.server? ...@@ -14,7 +14,10 @@ unless Sidekiq.server?
config.lograge.custom_options = lambda do |event| config.lograge.custom_options = lambda do |event|
{ {
time: event.time.utc.iso8601(3), time: event.time.utc.iso8601(3),
params: event.payload[:params].except(*%w(controller action format)) params: event.payload[:params].except(*%w(controller action format)),
remote_ip: event.payload[:remote_ip],
user_id: event.payload[:user_id],
username: event.payload[:username]
} }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment