From 9112d2d73bb12c2f4beb56fce335dd777186a128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= <15726+Senen@users.noreply.github.com> Date: Thu, 17 Aug 2023 17:58:57 +0200 Subject: [PATCH] Include a timestamp in every authentication logger message --- lib/authentication_logger.rb | 4 +++- spec/lib/authentication_logger_spec.rb | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/authentication_logger.rb b/lib/authentication_logger.rb index 8aa940bd7..510d68115 100644 --- a/lib/authentication_logger.rb +++ b/lib/authentication_logger.rb @@ -3,7 +3,9 @@ class AuthenticationLogger class << self def log(message) - logger.info(message) + logger.tagged(Time.current) do + logger.info(message) + end end def path diff --git a/spec/lib/authentication_logger_spec.rb b/spec/lib/authentication_logger_spec.rb index bcf40c11b..2e773072c 100644 --- a/spec/lib/authentication_logger_spec.rb +++ b/spec/lib/authentication_logger_spec.rb @@ -38,4 +38,12 @@ describe AuthenticationLogger do end end end + + describe "log" do + it "includes current time in each log entry", :with_frozen_time do + expect_any_instance_of(ActiveSupport::TaggedLogging).to receive(:tagged).with(Time.current) + + AuthenticationLogger.log("Just logging something!") + end + end end