diff --git a/lib/openhab/core.rb b/lib/openhab/core.rb index a53335fa38..0ad488ca26 100644 --- a/lib/openhab/core.rb +++ b/lib/openhab/core.rb @@ -38,7 +38,7 @@ class << self def wait_till_openhab_ready logger.trace("Checking readiness of openHAB") until automation_manager - logger.trace("Automation manager not loaded, checking again in #{CHECK_DELAY} seconds.") + logger.trace { "Automation manager not loaded, checking again in #{CHECK_DELAY} seconds." } sleep CHECK_DELAY end logger.trace "Automation manager instantiated, openHAB ready for rule processing." diff --git a/lib/openhab/core/actions.rb b/lib/openhab/core/actions.rb index 61cc7c1823..a61dd4f86c 100644 --- a/lib/openhab/core/actions.rb +++ b/lib/openhab/core/actions.rb @@ -37,7 +37,7 @@ module Actions else (java_import action_class.ruby_class).first end - logger.trace("Loaded ACTION: #{action_class}") + logger.trace { "Loaded ACTION: #{action_class}" } Object.const_set(module_name, action) end diff --git a/lib/openhab/core/items.rb b/lib/openhab/core/items.rb index 15a716dedb..09e3fbf70f 100644 --- a/lib/openhab/core/items.rb +++ b/lib/openhab/core/items.rb @@ -44,7 +44,7 @@ def def_predicate_methods(klass) _command_predicate, state_predicate = Types::PREDICATE_ALIASES[state.to_s] next if klass.instance_methods.include?(state_predicate) - logger.trace("Defining #{klass}##{state_predicate} for #{state}") + logger.trace { "Defining #{klass}##{state_predicate} for #{state}" } klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{state_predicate} # def on? raw_state.as(#{state.class.java_class.simple_name}).equal?(#{state}) # raw_state.as(OnOffType) == ON @@ -61,7 +61,7 @@ def def_command_methods(klass) next if klass.instance_methods.include?(command) if value.is_a?(Types::State) - logger.trace("Defining #{klass}/Enumerable##{command}/#{command}! for #{value}") + logger.trace { "Defining #{klass}/Enumerable##{command}/#{command}! for #{value}" } klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1 ruby2_keywords def #{command}(*args, &block) # ruby2_keywords def on(*args, &block) @@ -83,7 +83,7 @@ def #{command}! # def on! end # end RUBY else - logger.trace("Defining #{klass}/Enumerable##{command} for #{value}") + logger.trace { "Defining #{klass}/Enumerable##{command} for #{value}" } klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1 ruby2_keywords def #{command}(*args, &block) # ruby2_keywords def refresh(*args, &block) @@ -98,7 +98,7 @@ def #{command} # def refresh RUBY end - logger.trace("Defining ItemCommandEvent##{command}? for #{value}") + logger.trace { "Defining ItemCommandEvent##{command}? for #{value}" } Events::ItemCommandEvent.class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{command}? # def refresh? command.as(#{value.class.java_class.simple_name}).equal?(#{value}) # command.as(RefreshType).equal?(REFRESH) diff --git a/lib/openhab/core/items/generic_item.rb b/lib/openhab/core/items/generic_item.rb index 3fed90004e..2b11f9d051 100644 --- a/lib/openhab/core/items/generic_item.rb +++ b/lib/openhab/core/items/generic_item.rb @@ -276,7 +276,7 @@ def modify(force: false) raise FrozenError, "Cannot modify item #{name} from provider #{provider.inspect}." unless force provider = nil - logger.debug("Forcing modifications to non-managed item #{name}") + logger.debug { "Forcing modifications to non-managed item #{name}" } end @modified = false @modifying = true diff --git a/lib/openhab/core/items/image_item.rb b/lib/openhab/core/items/image_item.rb index 67f50529a1..ef53c0b459 100644 --- a/lib/openhab/core/items/image_item.rb +++ b/lib/openhab/core/items/image_item.rb @@ -55,7 +55,7 @@ def update_from_file(file, mime_type: nil) # # def update_from_url(uri) - logger.trace("Downloading image from #{uri}") + logger.trace { "Downloading image from #{uri}" } response = Net::HTTP.get_response(URI(uri)) mime_type = response["content-type"] bytes = response.body diff --git a/lib/openhab/core/items/metadata/namespace_hash.rb b/lib/openhab/core/items/metadata/namespace_hash.rb index 2159eecfb8..0e1031e067 100644 --- a/lib/openhab/core/items/metadata/namespace_hash.rb +++ b/lib/openhab/core/items/metadata/namespace_hash.rb @@ -73,7 +73,7 @@ def fetch(key, *default_value, &block) raise ArgumentError, "Wrong number of arguments (given #{default_value.length + 1}, expected 1..2)" end - logger.trace("Getting metadata for item: #{@item_name}, namespace '#{key}'") + logger.trace { "Getting metadata for item: #{@item_name}, namespace '#{key}'" } if (m = Provider.registry.get(MetadataKey.new(key, @item_name))) Hash.new(m) elsif block diff --git a/lib/openhab/core/items/semantics.rb b/lib/openhab/core/items/semantics.rb index 6a10e89dcd..e5c4ccf285 100644 --- a/lib/openhab/core/items/semantics.rb +++ b/lib/openhab/core/items/semantics.rb @@ -251,7 +251,7 @@ def lookup(id, locale = java.util.Locale.default) # # @!visibility private def const_missing(sym) - logger.trace("const missing, performing Semantics Lookup for: #{sym}") + logger.trace { "const missing, performing Semantics Lookup for: #{sym}" } lookup(sym)&.tap { |tag| const_set(sym, tag) } || super end end diff --git a/lib/openhab/core/profile_factory.rb b/lib/openhab/core/profile_factory.rb index 6470815452..1eedf04eb4 100644 --- a/lib/openhab/core/profile_factory.rb +++ b/lib/openhab/core/profile_factory.rb @@ -86,7 +86,9 @@ def onTimeSeriesFromHandler(time_series) private def process_event(event, **params) - logger.trace("Handling event #{event.inspect} in profile #{@uid} with param #{params.values.first.inspect}.") + logger.trace do + "Handling event #{event.inspect} in profile #{@uid} with param #{params.values.first.inspect}." + end params[:callback] = @callback params[:context] = @context diff --git a/lib/openhab/core/script_handling.rb b/lib/openhab/core/script_handling.rb index ed249ac4f5..5c52167ac9 100644 --- a/lib/openhab/core/script_handling.rb +++ b/lib/openhab/core/script_handling.rb @@ -119,7 +119,7 @@ def scriptUnloaded # rubocop:disable Naming/MethodName method name dictated by o # Executed when openHAB loads a script file # def scriptLoaded(filename) # rubocop:disable Naming/MethodName method name dictated by openHAB - logger.trace("Script loaded: #{filename}") + logger.trace { "Script loaded: #{filename}" } ScriptHandlingCallbacks.script_loaded_hooks.each do |hook| hook.call rescue => e diff --git a/lib/openhab/core/things/thing.rb b/lib/openhab/core/things/thing.rb index 53bd4b26ed..2127f128b5 100644 --- a/lib/openhab/core/things/thing.rb +++ b/lib/openhab/core/things/thing.rb @@ -256,7 +256,7 @@ def method_missing(method, *args, &block) # @!visibility private def respond_to_missing?(method_name, _include_private = false) - logger.trace("Checking if Thing #{uid} supports #{method_name} action") + logger.trace { "Checking if Thing #{uid} supports #{method_name} action" } return true if actions.respond_to?(method_name) super diff --git a/lib/openhab/core/types.rb b/lib/openhab/core/types.rb index 4eefa8c564..c284eb9edd 100644 --- a/lib/openhab/core/types.rb +++ b/lib/openhab/core/types.rb @@ -55,7 +55,7 @@ module Types states = Types::PREDICATE_ALIASES[value.to_s] ([command] | states).each do |method| - logger.trace("Defining #{klass}##{method} for #{value}") + logger.trace { "Defining #{klass}##{method} for #{value}" } klass.class_eval <<~RUBY, __FILE__, __LINE__ + 1 def #{method} # def on? as(#{value.class.java_class.simple_name}).equal?(#{value}) # as(OnOffType).equal?(ON) diff --git a/lib/openhab/core/types/date_time_type.rb b/lib/openhab/core/types/date_time_type.rb index 48c7772754..0b4b80f1f0 100644 --- a/lib/openhab/core/types/date_time_type.rb +++ b/lib/openhab/core/types/date_time_type.rb @@ -113,7 +113,7 @@ def eql?(other) # `nil` is returned if the two values are incomparable. # def <=>(other) - logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") + logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" } if other.is_a?(self.class) zoned_date_time <=> other.zoned_date_time elsif other.respond_to?(:to_time) @@ -135,7 +135,7 @@ def <=>(other) # @return [[DateTimeType, DateTimeType], nil] # def coerce(other) - logger.trace("Coercing #{self} as a request from #{other.class}") + logger.trace { "Coercing #{self} as a request from #{other.class}" } return [other, zoned_date_time] if other.respond_to?(:to_zoned_date_time) [DateTimeType.new(other), self] if other.respond_to?(:to_time) diff --git a/lib/openhab/core/types/decimal_type.rb b/lib/openhab/core/types/decimal_type.rb index 84dca3c68c..7b0065e7a8 100644 --- a/lib/openhab/core/types/decimal_type.rb +++ b/lib/openhab/core/types/decimal_type.rb @@ -91,7 +91,7 @@ def |(other) # `nil` is returned if the two values are incomparable. # def <=>(other) - logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") + logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" } if other.is_a?(QuantityType) || other.is_a?(HSBType) (other <=> self)&.-@ elsif other.is_a?(self.class) @@ -115,7 +115,7 @@ def <=>(other) # @return [Array<(DecimalType, DecimalType)>, nil] # def coerce(other) - logger.trace("Coercing #{self} as a request from #{other.class}") + logger.trace { "Coercing #{self} as a request from #{other.class}" } return unless other.respond_to?(:to_d) [self.class.new(other.to_d), self] diff --git a/lib/openhab/core/types/hsb_type.rb b/lib/openhab/core/types/hsb_type.rb index e1f9dfdcee..a44b033f1d 100644 --- a/lib/openhab/core/types/hsb_type.rb +++ b/lib/openhab/core/types/hsb_type.rb @@ -65,7 +65,7 @@ def new(*args) # in this case, HTML hex format for rgb if (match = value.match(/^#(\h{2})(\h{2})(\h{2})$/)) rgb = match.to_a[1..3].map { |v| v.to_i(16) } - logger.trace("creating from rgb #{rgb.inspect}") + logger.trace { "creating from rgb #{rgb.inspect}" } return from_rgb(*rgb) end end @@ -110,7 +110,7 @@ def new(*args) # `nil` is returned if the two values are incomparable. # def <=>(other) - logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") + logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" } if other.is_a?(HSBType) [brightness, hue, saturation] <=> [other.brightness, other.hue, other.saturation] else diff --git a/lib/openhab/core/types/point_type.rb b/lib/openhab/core/types/point_type.rb index 3d0f3c42ce..28f307be63 100644 --- a/lib/openhab/core/types/point_type.rb +++ b/lib/openhab/core/types/point_type.rb @@ -103,7 +103,7 @@ def altitude # # @return [QuantityType] def distance_from(other) - logger.trace("(#{self}).distance_from(#{other} (#{other.class})") + logger.trace { "(#{self}).distance_from(#{other} (#{other.class})" } raise TypeError, "#{other.class} can't be coerced into #{self.class}" unless other.is_a?(PointType) QuantityType.new(raw_distance_from(other), SIUnits::METRE) diff --git a/lib/openhab/core/types/quantity_type.rb b/lib/openhab/core/types/quantity_type.rb index bbfa9716c0..8ee1d98edb 100644 --- a/lib/openhab/core/types/quantity_type.rb +++ b/lib/openhab/core/types/quantity_type.rb @@ -132,7 +132,7 @@ class QuantityType # `nil` is returned if the two values are incomparable. # def <=>(other) - logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") + logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" } case other when self.class return unitize(other.unit).compare_to(other) if unit == Units::ONE @@ -161,7 +161,7 @@ def <=>(other) # # @return [Array<(QuantityType, QuantityType)>, nil] def coerce(other) - logger.trace("Coercing #{self} as a request from #{other.class}") + logger.trace { "Coercing #{self} as a request from #{other.class}" } return unless other.respond_to?(:to_d) [QuantityType.new(other.to_d.to_java, Units::ONE), self] @@ -178,7 +178,7 @@ def coerce(other) class_eval( # rubocop:disable Style/DocumentDynamicEvalDefinition https://github.com/rubocop/rubocop/issues/10179 # def +(other) - # logger.trace("#{self} + #{other} (#{other.class})") + # logger.trace { "#{self} + #{other} (#{other.class})" } # other = other.state if other.is_a?(Core::Items::Persistence::PersistedState) # if other.is_a?(QuantityType) # add_quantity(other) @@ -203,7 +203,7 @@ def coerce(other) # end <<~RUBY, __FILE__, __LINE__ + 1 def #{ruby_op}(other) - logger.trace("\#{self} #{ruby_op} \#{other} (\#{other.class})") + logger.trace { "\#{self} #{ruby_op} \#{other} (\#{other.class})" } other = other.state if other.is_a?(Core::Items::Persistence::PersistedState) if other.is_a?(QuantityType) #{java_op}_quantity(other) @@ -236,7 +236,7 @@ def #{ruby_op}(other) }.each do |java_op, ruby_op| class_eval( # rubocop:disable Style/DocumentDynamicEvalDefinition https://github.com/rubocop/rubocop/issues/10179 # def *(other) - # logger.trace("#{self} * #{other} (#{other.class})") + # logger.trace { "#{self} * #{other} (#{other.class})" } # other = other.state if other.is_a?(Core::Items::Persistence::PersistedState) # if other.is_a?(QuantityType) # multiply_quantity(other) @@ -254,7 +254,7 @@ def #{ruby_op}(other) # end <<~RUBY, __FILE__, __LINE__ + 1 def #{ruby_op}(other) - logger.trace("\#{self} #{ruby_op} \#{other} (\#{other.class})") + logger.trace { "\#{self} #{ruby_op} \#{other} (\#{other.class})" } other = other.state if other.is_a?(Core::Items::Persistence::PersistedState) if other.is_a?(QuantityType) #{java_op}_quantity(other).unitize @@ -279,7 +279,7 @@ def #{ruby_op}(other) def unitize(other_unit = unit, relative: false) # prefer converting to the thread-specified unit if there is one other_unit = DSL.unit(dimension) || other_unit - logger.trace("Converting #{self} to #{other_unit}") + logger.trace { "Converting #{self} to #{other_unit}" } case unit when Units::ONE diff --git a/lib/openhab/core/types/string_type.rb b/lib/openhab/core/types/string_type.rb index 4595b87518..48671d318b 100644 --- a/lib/openhab/core/types/string_type.rb +++ b/lib/openhab/core/types/string_type.rb @@ -41,7 +41,7 @@ def eql?(other) # `nil` is returned if the two values are incomparable. # def <=>(other) - logger.trace("(#{self.class}) #{self} <=> #{other} (#{other.class})") + logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" } if other.respond_to?(:to_str) to_str <=> other.to_str elsif other.respond_to?(:coerce) @@ -61,7 +61,7 @@ def <=>(other) # @return [[StringType, StringType], nil] # def coerce(other) - logger.trace("Coercing #{self} as a request from #{other.class}") + logger.trace { "Coercing #{self} as a request from #{other.class}" } [other.to_str, self] if other.respond_to?(:to_str) end diff --git a/lib/openhab/core_ext/java/month_day.rb b/lib/openhab/core_ext/java/month_day.rb index 8c4885ab4a..196291e79c 100644 --- a/lib/openhab/core_ext/java/month_day.rb +++ b/lib/openhab/core_ext/java/month_day.rb @@ -20,7 +20,7 @@ class << self # @return [MonthDay] # def parse(string) - logger.trace("#{self.class}.parse #{string} (#{string.class})") + logger.trace { "#{self.class}.parse #{string} (#{string.class})" } java_send(:parse, [java.lang.CharSequence, java.time.format.DateTimeFormatter], string.to_s, diff --git a/lib/openhab/dsl.rb b/lib/openhab/dsl.rb index 1409aeb185..fa245e1db9 100644 --- a/lib/openhab/dsl.rb +++ b/lib/openhab/dsl.rb @@ -1106,10 +1106,10 @@ def try_parse_time_like(string) return super unless args.empty? && !block_given? if (context = Thread.current[:openhab_context]) && context.key?(method) - logger.trace("DSL#method_missing found context variable: '#{method}'") + logger.trace { "DSL#method_missing found context variable: '#{method}'" } return context[method] elsif Core.ui_context&.key?(method) - logger.trace("DSL#method_missing found UI context variable: '#{method}'") + logger.trace { "DSL#method_missing found UI context variable: '#{method}'" } return Core.ui_context[method] end super diff --git a/lib/openhab/dsl/rules/automation_rule.rb b/lib/openhab/dsl/rules/automation_rule.rb index 1840b3b0fa..ffa0dcf836 100644 --- a/lib/openhab/dsl/rules/automation_rule.rb +++ b/lib/openhab/dsl/rules/automation_rule.rb @@ -104,7 +104,7 @@ def listen_for_removal @listener ||= org.openhab.core.common.registry.RegistryChangeListener.impl do |method, element| next unless method == :removed - logger.trace("Rule #{element.inspect} removed from registry") + logger.trace { "Rule #{element.inspect} removed from registry" } next unless element.uid == uid cleanup @@ -225,7 +225,7 @@ def check_guards(event:) return true if @guard.should_run?(event) - logger.trace("Skipped execution of rule '#{name}' because of guard #{@guard}") + logger.trace { "Skipped execution of rule '#{name}' because of guard #{@guard}" } false end diff --git a/lib/openhab/dsl/rules/guard.rb b/lib/openhab/dsl/rules/guard.rb index 71917224e4..3726841c9f 100644 --- a/lib/openhab/dsl/rules/guard.rb +++ b/lib/openhab/dsl/rules/guard.rb @@ -37,7 +37,7 @@ def to_s # @return [true,false] True if guard is satisfied, false otherwise # def should_run?(event) - logger.trace("Checking guards #{self}") + logger.trace { "Checking guards #{self}" } return false unless check_only_if(event) return false unless check_not_if(event) diff --git a/lib/openhab/dsl/rules/rule_triggers.rb b/lib/openhab/dsl/rules/rule_triggers.rb index fdd0910e39..c03fdb80e4 100644 --- a/lib/openhab/dsl/rules/rule_triggers.rb +++ b/lib/openhab/dsl/rules/rule_triggers.rb @@ -44,7 +44,7 @@ def initialize def append_trigger(type:, config:, attach: nil, conditions: nil, label: nil) config.transform_keys!(&:to_s) RuleTriggers.trigger(type: type, config: config, label: label).tap do |trigger| - logger.trace("Appending trigger (#{trigger.inspect}) attach (#{attach}) conditions(#{conditions})") + logger.trace { "Appending trigger (#{trigger.inspect}) attach (#{attach}) conditions(#{conditions})" } @triggers << trigger @attachments[trigger.id] = attach if attach @trigger_conditions[trigger.id] = conditions if conditions @@ -61,7 +61,7 @@ def append_trigger(type:, config:, attach: nil, conditions: nil, label: nil) # @return [org.openhab.core.automation.Trigger] configured by type and supplied config # def self.trigger(type:, config:, label: nil) - logger.trace("Creating trigger of type '#{type}' config: #{config}") + logger.trace { "Creating trigger of type '#{type}' config: #{config}" } org.openhab.core.automation.util.TriggerBuilder.create .with_id(uuid) .with_type_uid(type) diff --git a/lib/openhab/dsl/rules/triggers/conditions/duration.rb b/lib/openhab/dsl/rules/triggers/conditions/duration.rb index 27e34e11cb..3b97912fb6 100644 --- a/lib/openhab/dsl/rules/triggers/conditions/duration.rb +++ b/lib/openhab/dsl/rules/triggers/conditions/duration.rb @@ -22,8 +22,10 @@ def initialize(to:, from:, duration:) @conditions = Generic.new(to: to, from: from) @duration = duration @timers = {} - logger.trace "Created Duration Condition To(#{to}) From(#{from}) " \ - "Conditions(#{@conditions}) Duration(#{@duration})" + logger.trace do + "Created Duration Condition To(#{to}) From(#{from}) " \ + "Conditions(#{@conditions}) Duration(#{@duration})" + end end # Process rule @@ -34,13 +36,13 @@ def process(mod:, inputs:, &block) if timer&.active? process_active_timer(timer, inputs, mod, &block) elsif @conditions.process(mod: mod, inputs: inputs) - logger.trace("Trigger Guards Matched for #{self}, delaying rule execution") + logger.trace { "Trigger Guards Matched for #{self}, delaying rule execution" } # Add timer and attach timer to delay object, and also state being tracked to so # timer can be cancelled if state changes # Also another timer should not be created if changed to same value again but instead rescheduled create_trigger_delay_timer(inputs, mod, &block) else - logger.trace("Trigger Guards did not match for #{self}, ignoring trigger.") + logger.trace { "Trigger Guards did not match for #{self}, ignoring trigger." } end end @@ -61,10 +63,10 @@ def cleanup # # def create_trigger_delay_timer(inputs, _mod) - logger.trace("Creating timer for trigger delay #{self}") + logger.trace { "Creating timer for trigger delay #{self}" } item_name = inputs["triggeringItem"]&.name @timers[item_name] = DSL.after(@duration) do - logger.trace("Delay Complete for #{self}, executing rule") + logger.trace { "Delay Complete for #{self}, executing rule" } @timers.delete(item_name) yield end @@ -83,9 +85,9 @@ def process_active_timer(timer, inputs, mod, &block) new_state = Conditions.new_state_from(inputs) if @conditions.from? && new_state != @tracking_from && @conditions.process(mod: nil, inputs: { "state" => new_state }) - logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, keep waiting.") + logger.trace { "Item changed from #{old_state} to #{new_state} for #{self}, keep waiting." } else - logger.trace("Item changed from #{old_state} to #{new_state} for #{self}, canceling timer.") + logger.trace { "Item changed from #{old_state} to #{new_state} for #{self}, canceling timer." } timer.cancel # Reprocess trigger delay after canceling to track new state (if guards matched, etc) process(mod: mod, inputs: inputs, &block) diff --git a/lib/openhab/dsl/rules/triggers/conditions/generic.rb b/lib/openhab/dsl/rules/triggers/conditions/generic.rb index 92a43ab926..bf59bbe10b 100644 --- a/lib/openhab/dsl/rules/triggers/conditions/generic.rb +++ b/lib/openhab/dsl/rules/triggers/conditions/generic.rb @@ -30,7 +30,7 @@ def initialize(from: nil, to: nil, command: nil) # @return [true, false] if the conditions passed (and therefore the block was run) # def process(mod:, inputs:) - logger.trace("Checking #{inputs} against condition trigger #{self}") + logger.trace { "Checking #{inputs} against condition trigger #{self}" } unless check_value(Conditions.old_state_from(inputs), @from) && check_value(Conditions.new_state_from(inputs), @to) && check_value(inputs["command"], @command) diff --git a/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb b/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb index 3494226e50..05089cbf4e 100644 --- a/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb +++ b/lib/openhab/dsl/rules/triggers/cron/cron_handler.rb @@ -45,7 +45,7 @@ def setCallback(callback) # rubocop:disable Naming/MethodName synchronized do super(callback) @schedule = @scheduler.schedule(self, @expression) - logger.trace("Scheduled cron job '#{@expression}' for trigger '#{@trigger.id}'.") + logger.trace { "Scheduled cron job '#{@expression}' for trigger '#{@trigger.id}'." } end end @@ -76,7 +76,7 @@ def dispose @schedule.cancel(true) @schedule = nil end - logger.trace("cancelled job for trigger '#{@trigger.id}'.") + logger.trace { "cancelled job for trigger '#{@trigger.id}'." } end end diff --git a/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb b/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb index 3f355ce6ce..ca0b9a9f43 100644 --- a/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb +++ b/lib/openhab/dsl/rules/triggers/watch/watch_handler.rb @@ -140,7 +140,7 @@ def getWatchEventKinds(_path) # Invoked by java super class to check if sub directories should be watched # @return [false] false def watchSubDirectories - logger.trace("watchSubDirectories returning #{@subdirs}") + logger.trace { "watchSubDirectories returning #{@subdirs}" } @subdirs end diff --git a/lib/openhab/dsl/timer_manager.rb b/lib/openhab/dsl/timer_manager.rb index f0d934ec4b..5c4c18e6dd 100644 --- a/lib/openhab/dsl/timer_manager.rb +++ b/lib/openhab/dsl/timer_manager.rb @@ -45,7 +45,7 @@ def create(duration, thread_locals:, block:, id:, reschedule:) # Add a timer that is now active # @!visibility private def add(timer) - logger.trace("Adding #{timer} to timers") + logger.trace { "Adding #{timer} to timers" } @timers[timer] = 1 end @@ -54,7 +54,7 @@ def add(timer) # # @!visibility private def delete(timer) - logger.trace("Removing #{timer} from timers") + logger.trace { "Removing #{timer} from timers" } return unless @timers.remove(timer) && timer.id @timers_by_id.remove(timer.id) @@ -193,7 +193,7 @@ def cancel_all logged = false # don't use #each, in case timers are scheduling more timers until @timers.empty? - logger.trace("Canceling #{@timers.length} timers") unless logged + logger.trace { "Canceling #{@timers.length} timers" } unless logged logged = true timer = @timers.keys.first timer.cancel diff --git a/lib/openhab/rspec/mocks/event_admin.rb b/lib/openhab/rspec/mocks/event_admin.rb index 16fbc277b0..37408acde5 100644 --- a/lib/openhab/rspec/mocks/event_admin.rb +++ b/lib/openhab/rspec/mocks/event_admin.rb @@ -35,7 +35,7 @@ def handle_event(osgi_event) def handle_event_internal(type, payload, topic, source) event_factory = @typed_event_factories[type] unless event_factory - logger.debug("Could not find an Event Factory for the event type '#{type}'.") + logger.debug { "Could not find an Event Factory for the event type '#{type}'." } return end @@ -78,6 +78,7 @@ def dispatch_event(event_subscribers, event) ) end else + # Changing this to block syntax will cause specs to fail, for some reason. logger.trace("Skip event subscriber (#{event_subscriber.class}) because of its filter.") end end diff --git a/lib/openhab/rspec/openhab/core/actions.rb b/lib/openhab/rspec/openhab/core/actions.rb index de85eaa155..56f2363eca 100644 --- a/lib/openhab/rspec/openhab/core/actions.rb +++ b/lib/openhab/rspec/openhab/core/actions.rb @@ -20,7 +20,7 @@ def send_notification( button2 = nil, button3 = nil ) - logger.debug("send_notification: #{email}, #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength + logger.debug { "send_notification: #{email}, #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}" } # rubocop:disable Layout/LineLength end def send_broadcast_notification( @@ -35,23 +35,23 @@ def send_broadcast_notification( button2 = nil, button3 = nil ) - logger.debug("send_broadcast_notification: #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}") # rubocop:disable Layout/LineLength + logger.debug { "send_broadcast_notification: #{msg}, #{icon}, #{tag}, #{title}, #{id}, #{on_click}, #{attachment}, #{button1}, #{button2}, #{button3}" } # rubocop:disable Layout/LineLength end def hide_notification_by_reference_id(email, id) - logger.debug("hide_notification_by_reference_id: #{email}, #{id}") + logger.debug { "hide_notification_by_reference_id: #{email}, #{id}" } end def hide_notification_by_tag(email, tag) - logger.debug("hide_notification_by_tag: #{email}, #{tag}") + logger.debug { "hide_notification_by_tag: #{email}, #{tag}" } end def hide_broadcast_notification_by_reference_id(id) - logger.debug("hide_broadcast_notification_by_reference_id: #{id}") + logger.debug { "hide_broadcast_notification_by_reference_id: #{id}" } end def hide_broadcast_notification_by_tag(tag) - logger.debug("hide_broadcast_notification_by_tag: #{tag}") + logger.debug { "hide_broadcast_notification_by_tag: #{tag}" } end end end @@ -59,7 +59,7 @@ def hide_broadcast_notification_by_tag(tag) class Voice class << self def say(text, voice: nil, sink: nil, volume: nil) - logger.debug("say: #{text}") + logger.debug { "say: #{text}" } end end end @@ -67,11 +67,11 @@ def say(text, voice: nil, sink: nil, volume: nil) class Audio class << self def play_sound(filename, sink: nil, volume: nil) - logger.debug("play_sound: #{filename}") + logger.debug { "play_sound: #{filename}" } end def play_stream(url, sink: nil) - logger.debug("play_stream: #{url}") + logger.debug { "play_stream: #{url}" } end end end diff --git a/lib/openhab/rspec/suspend_rules.rb b/lib/openhab/rspec/suspend_rules.rb index 9b72685439..67f896c1b6 100644 --- a/lib/openhab/rspec/suspend_rules.rb +++ b/lib/openhab/rspec/suspend_rules.rb @@ -9,7 +9,7 @@ module SuspendRules class ::OpenHAB::DSL::Rules::AutomationRule # rubocop:disable Style/ClassAndModuleChildren def execute(mod = nil, inputs = nil) if SuspendRules.suspended? - logger.trace("Skipping execution of #{uid} because rules are suspended.") + logger.trace { "Skipping execution of #{uid} because rules are suspended." } return end execute!(mod, inputs)