Class: ExtendedLogger::Formatter
- Inherits:
-
Object
- Object
- ExtendedLogger::Formatter
- Defined in:
- lib/extended_logger/formatter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
Instance Method Summary collapse
- #call(*arguments) ⇒ Object
- #delegate(*arguments, message) ⇒ Object
- #format_message(message, arguments) ⇒ Object
Instance Attribute Details
#logger_formatter ⇒ Object
35 36 37 |
# File 'lib/extended_logger/formatter.rb', line 35 def logger_formatter @logger_formatter ||= Logger::Formatter.new end |
Instance Method Details
#call(*arguments) ⇒ Object
5 6 7 |
# File 'lib/extended_logger/formatter.rb', line 5 def call *arguments delegate *arguments end |
#delegate(*arguments, message) ⇒ Object
9 10 11 12 |
# File 'lib/extended_logger/formatter.rb', line 9 def delegate *arguments, = , arguments logger_formatter.(*arguments, ) end |
#format_message(message, arguments) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/extended_logger/formatter.rb', line 14 def , arguments output = '' .each_line "\n".freeze do |line| if line == "\n".freeze line = "\\n" else line.gsub! "\r".freeze, "\\r".freeze end if output.empty? output.concat line else formatted_line = logger_formatter.(*arguments, line.chomp("\n".freeze)) output.concat formatted_line end end output.chomp "\n".freeze end |