Class: Epuber::Logger::ConsoleLogger

Inherits:
AbstractLogger show all
Defined in:
lib/epuber/utils/logger/console_logger.rb

Constant Summary

Constants inherited from AbstractLogger

AbstractLogger::LEVELS

Instance Attribute Summary

Attributes inherited from AbstractLogger

#debug_steps_times, #verbose

Instance Method Summary collapse

Methods inherited from AbstractLogger

#debug, #end_processing, #error, #error!, #error?, #info, #initialize, #print_processing_debug_info, #print_step_processing_time, #start_processing_file, #warning

Constructor Details

This class inherits a constructor from Epuber::Logger::AbstractLogger

Instance Method Details

#_log(level, message, location: nil, backtrace: nil, sticky: false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/epuber/utils/logger/console_logger.rb', line 8

def _log(level, message, location: nil, backtrace: nil, sticky: false)
  prev_line = _remove_sticky_message

  # save sticky message
  @sticky_message = message if sticky

  formatted_message = _format_message(level, message, location: location, backtrace: backtrace)

  # print the message
  if sticky
    $stdout.print(formatted_message)
  else
    $stdout.puts(formatted_message)

    # reprint previous sticky message when this message is not sticky
    if prev_line
      @sticky_message = prev_line
      $stdout.print(prev_line)
    end
  end
end