summaryrefslogtreecommitdiff
path: root/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb')
-rw-r--r--lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
new file mode 100644
index 00000000000..1e1fdabca93
--- /dev/null
+++ b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
@@ -0,0 +1,19 @@
+module Gitlab
+ module GrapeLogging
+ module Formatters
+ class LogrageWithTimestamp
+ def call(severity, datetime, _, data)
+ time = data.delete :time
+ attributes = {
+ time: datetime.utc.iso8601(3),
+ severity: severity,
+ duration: time[:total],
+ db: time[:db],
+ view: time[:view]
+ }.merge(data)
+ ::Lograge.formatter.call(attributes) + "\n"
+ end
+ end
+ end
+ end
+end