From f3c7bbe3412c99259abd3d2e437c2a375cdadef1 Mon Sep 17 00:00:00 2001 From: Jimmy Tanagra Date: Sat, 5 Oct 2024 06:23:31 +1000 Subject: [PATCH] Fix logger error when no toplevel file is found Signed-off-by: Jimmy Tanagra --- lib/openhab/log.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/openhab/log.rb b/lib/openhab/log.rb index d605ab9e5..d3ccc708f 100644 --- a/lib/openhab/log.rb +++ b/lib/openhab/log.rb @@ -114,7 +114,7 @@ def logger(object) # @!visibility private def top_level_file caller_locations.find { |caller| caller.base_label == "
" } - .then { |caller| cleanup_path(caller.path) } + &.then { |caller| cleanup_path(caller.path) } end private @@ -376,9 +376,10 @@ def current_logger return @file_logger unless (rule_uid = Thread.current[:openhab_rule_uid]) rule_type = Thread.current[:openhab_rule_type] + top_level_file = Log.top_level_file&.then { |file| "#{file}." } full_id = "#{rule_type}:#{rule_uid}" - self.class.rule_loggers[full_id] ||= Logger.new("#{Logger::PREFIX}.#{Log.top_level_file}.#{rule_type}.#{rule_uid + self.class.rule_loggers[full_id] ||= Logger.new("#{Logger::PREFIX}.#{top_level_file}#{rule_type}.#{rule_uid .gsub(/[^A-Za-z0-9_.:-]/, "")}") end