summaryrefslogtreecommitdiff
path: root/lib/gitlab/grape_logging
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-20 18:12:28 +0000
committerMayra Cabrera <mcabrera@gitlab.com>2019-08-20 18:12:28 +0000
commite632ae80845f849f93e4d85ef9f836a4792844c9 (patch)
tree5715c29c7a6b6ed93e16f8ab0f59b229af3ba646 /lib/gitlab/grape_logging
parenta493cccdda6d2ab0fd21e60a144504a6cf6747ee (diff)
downloadgitlab-ce-e632ae80845f849f93e4d85ef9f836a4792844c9.tar.gz
Standardize remote_ip and path keys for auth.log and api_json.log
Current `auth.log` uses `fullpath` and `ip`, while `api_json.log` uses `remote_ip` and `path` for the same fields. Let's standardize these namings to make it easier for people working with the data. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/66167
Diffstat (limited to 'lib/gitlab/grape_logging')
-rw-r--r--lib/gitlab/grape_logging/loggers/client_env_logger.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/grape_logging/loggers/client_env_logger.rb b/lib/gitlab/grape_logging/loggers/client_env_logger.rb
new file mode 100644
index 00000000000..3acc6f6a2ef
--- /dev/null
+++ b/lib/gitlab/grape_logging/loggers/client_env_logger.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+# This is a fork of
+# https://github.com/aserafin/grape_logging/blob/master/lib/grape_logging/loggers/client_env.rb
+# to use remote_ip instead of ip.
+module Gitlab
+ module GrapeLogging
+ module Loggers
+ class ClientEnvLogger < ::GrapeLogging::Loggers::Base
+ def parameters(request, _)
+ { remote_ip: request.env["HTTP_X_FORWARDED_FOR"] || request.env["REMOTE_ADDR"], ua: request.env["HTTP_USER_AGENT"] }
+ end
+ end
+ end
+ end
+end