class SmartLoggerWrapper::Options::WithPosition
Public Instance Methods
apply!(messages, arguments, severity, wrapper)
click to toggle source
# File lib/smart_logger_wrapper/options/with_position.rb, line 12 def apply!(messages, arguments, severity, wrapper) enabled = arguments.first || true return unless enabled # add 1 to `start` because this method dug the backtrace by 1 location = caller_locations(wrapper.offset + APPLY_CALLER_STACK_DEPTH + 1, 1) prefix = if location && location.length > 0 && location_important?(location) method_name = location[0].label path = trim_dirname(location[0].absolute_path) lineno = location[0].lineno "[#{method_name}@#{path}:#{lineno}]" else nil end messages.map! { |message| [prefix, message].compact.join(' ') } end
Private Instance Methods
location_important?(location)
click to toggle source
# File lib/smart_logger_wrapper/options/with_position.rb, line 31 def location_important?(location) ! clean_backtrace(location.map(&:to_s), keeps_first: false).empty? end