debian-mirror-gitlab/lib/gitlab/grape_logging/loggers/context_logger.rb

22 lines
673 B
Ruby
Raw Normal View History

2020-05-24 23:13:21 +05:30
# frozen_string_literal: true
2021-11-18 22:05:49 +05:30
# This class adds application context to the grape logger
2020-05-24 23:13:21 +05:30
module Gitlab
module GrapeLogging
module Loggers
class ContextLogger < ::GrapeLogging::Loggers::Base
2021-11-18 22:05:49 +05:30
def parameters(request, _)
# Add remote_ip if this request wasn't already handled. If we
# add it unconditionally we can break client_id due to the way
# the context inherits the user.
unless Gitlab::ApplicationContext.current_context_include?(:remote_ip)
Gitlab::ApplicationContext.push(remote_ip: request.ip)
end
2021-04-29 21:17:54 +05:30
Gitlab::ApplicationContext.current
2020-05-24 23:13:21 +05:30
end
end
end
end
end