Class: SmartLoggerWrapper::Options::WithPosition
- Includes:
- Utils::Path
- Defined in:
- lib/smart_logger_wrapper/options/with_position.rb
Constant Summary
Constants included from Utils::Path
Utils::Path::DIR_TRIMMER_PATTERN
Instance Method Summary collapse
Methods included from Utils::Path
Instance Method Details
#apply!(messages, argument, severity, wrapper) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/smart_logger_wrapper/options/with_position.rb', line 10 def apply!(, argument, severity, wrapper) return if argument == false # 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 method_name = location[0].label path = trim_dirname(location[0].absolute_path) lineno = location[0].lineno "[#{method_name}@#{path}:#{lineno}]" else nil end .map! { || [prefix, ].compact.join(' ') } end |