diff options
Diffstat (limited to 'config/initializers/lograge.rb')
-rw-r--r-- | config/initializers/lograge.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb index d5d4c589884..769ef2af0e7 100644 --- a/config/initializers/lograge.rb +++ b/config/initializers/lograge.rb @@ -10,6 +10,11 @@ unless Sidekiq.server? # unmaintained gem that monkey patches `Time` config.lograge.formatter = Lograge::Formatters::Json.new config.lograge.logger = ActiveSupport::Logger.new(filename) + config.lograge.before_format = lambda do |data, payload| + data.delete(:error) + data + end + # Add request parameters to log output config.lograge.custom_options = lambda do |event| params = event.payload[:params] @@ -36,6 +41,20 @@ unless Sidekiq.server? payload[:cpu_s] = cpu_s end + # https://github.com/roidrage/lograge#logging-errors--exceptions + exception = event.payload[:exception_object] + + if exception + payload[:exception] = { + class: exception.class.name, + message: exception.message + } + + if exception.backtrace + payload[:exception][:backtrace] = Gitlab::Profiler.clean_backtrace(exception.backtrace) + end + end + payload end end |