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:
authorSean McGivern <sean@mcgivern.me.uk>2017-09-07 20:39:14 +0300
committerSean McGivern <sean@mcgivern.me.uk>2017-09-07 20:39:14 +0300
commit7e19b5bfb6e1e209388fa5464a980aa742fdd8c3 (patch)
tree9296679fbbe1ff75eddd47f85dd44dc1dcd55b9c /lib/api/api.rb
parent66f08aad714b7d43333db1251474a11f1815ec4c (diff)
parent35dec2c3e87f2f44c3ab0269e7f737afdc28801a (diff)
Merge branch 'sh-add-grape-logging' into 'master'
Add JSON logger in `log/api_json.log` for Grape API endpoints Closes #36189 See merge request !14102
Diffstat (limited to 'lib/api/api.rb')
-rw-r--r--lib/api/api.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb
index d9a62bffb6d..ee4e1688e12 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -2,6 +2,17 @@ module API
class API < Grape::API
include APIGuard
+ LOG_FILENAME = Rails.root.join("log", "api_json.log")
+
+ use GrapeLogging::Middleware::RequestLogger,
+ logger: Logger.new(LOG_FILENAME),
+ formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new,
+ include: [
+ GrapeLogging::Loggers::Response.new,
+ GrapeLogging::Loggers::FilterParameters.new,
+ GrapeLogging::Loggers::ClientEnv.new
+ ]
+
allow_access_with_scope :api
prefix :api