From 56e391e2bb3326c2cc6df84f81a638a1f7f72d93 Mon Sep 17 00:00:00 2001 From: Wouter Smeenk Date: Mon, 15 Apr 2024 15:19:08 +0200 Subject: [PATCH] Add duration and duration_ms for logfmt format Log processors sometimes parse duration_human as string (because of the added 'ms') which is not always useful. --- CHANGELOG.md | 1 + lib/semantic_logger/formatters/logfmt.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 841261f5..d98755a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Add support for Ruby 3.3 - Allow SyncProcessor to be called from appenders - Fix incorrect metrics usage examples in documentation +- Add `:duration_ms` to Logfmt fomatter ## [4.15.0] diff --git a/lib/semantic_logger/formatters/logfmt.rb b/lib/semantic_logger/formatters/logfmt.rb index 279407b8..9dddc7f1 100644 --- a/lib/semantic_logger/formatters/logfmt.rb +++ b/lib/semantic_logger/formatters/logfmt.rb @@ -31,7 +31,7 @@ def call(log, logger) private def raw_to_logfmt - @parsed = @raw.slice(time_key, :level, :name, :message, :duration).merge(tag: "success") + @parsed = @raw.slice(time_key, :level, :name, :message, :duration, :duration_ms).merge(tag: "success") handle_tags handle_payload handle_exception