Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2017-07-28 08:48:03 +0300
committerStan Hu <stanhu@gmail.com>2017-07-28 08:48:03 +0300
commit9bc176b2c39f1c27ce8ed4c13cf06e53331c16c9 (patch)
tree4e9ebd96d3b43be8c99f6afdad5296dfbaef55e6 /app/controllers/application_controller.rb
parent02b25598cbedaaec96d8c9e52de7f969a5eb71a1 (diff)
Add remote IP, user ID and username to JSON lograge output
This makes the logs a bit more useful to search requests by users.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 43462b13903..d14b1dbecf6 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -70,6 +70,16 @@ class ApplicationController < ActionController::Base
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
def authenticate_user_from_private_token!
token = params[:private_token].presence || request.headers['PRIVATE-TOKEN'].presence