From 050188102e41525a7e61a540dbef815d6316d6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Thu, 2 Dec 2021 14:55:18 +0100 Subject: [PATCH 1/2] Refactor `Log::BroadcastBackend#single_backend?` Simplifies the implementation. --- src/log/broadcast_backend.cr | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/log/broadcast_backend.cr b/src/log/broadcast_backend.cr index b6b558164020..d36ac88d90fb 100644 --- a/src/log/broadcast_backend.cr +++ b/src/log/broadcast_backend.cr @@ -36,13 +36,8 @@ class Log::BroadcastBackend < Log::Backend # :nodoc: def single_backend? - first_backend = @backends.first_key? - first_level = @backends[first_backend] - - if first_backend && @backends.size == 1 - {first_backend, first_level} - else - nil + if @backends.size == 1 + {@backends.first_key, @backends.first_value} end end From 965dde47f6c7506f682a0bc2e5dd737bb504ca6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Thu, 2 Dec 2021 16:35:20 +0100 Subject: [PATCH 2/2] Update src/log/broadcast_backend.cr Co-authored-by: Ary Borenszweig --- src/log/broadcast_backend.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log/broadcast_backend.cr b/src/log/broadcast_backend.cr index d36ac88d90fb..cdef277327d4 100644 --- a/src/log/broadcast_backend.cr +++ b/src/log/broadcast_backend.cr @@ -37,7 +37,7 @@ class Log::BroadcastBackend < Log::Backend # :nodoc: def single_backend? if @backends.size == 1 - {@backends.first_key, @backends.first_value} + @backends.first end end