9818: Log params when small, first 1K of json-encoded params when big.
[arvados.git] / apps / workbench / config / initializers / lograge.rb
index a41384bbe032560f418b32414c4307484c630f39..24252c8aa7c928ef117fe24ffd0f4011cddeca0e 100644 (file)
@@ -1,4 +1,14 @@
 ArvadosWorkbench::Application.configure do
   config.lograge.enabled = true
   config.lograge.formatter = Lograge::Formatters::Logstash.new
+  config.lograge.custom_options = lambda do |event|
+    exceptions = %w(controller action format id)
+    params = event.payload[:params].except(*exceptions)
+    params_s = Oj.dump(params)
+    if params_s.length > 1000
+      { params_truncated: params_s[0..1000] + "[...]" }
+    else
+      { params: params }
+    end
+  end
 end