class UltraMarathon::Logger
Constants
- NEW_LINE
Public Instance Methods
contents()
click to toggle source
Returns a copy of the log data so it cannot be externally altered
# File lib/ultra_marathon/logger.rb, line 25 def contents log_string.dup end
error(error)
click to toggle source
# File lib/ultra_marathon/logger.rb, line 16 def error(error) if error.is_a? Exception log_formatted_error(error) else info error end end
Also aliased as: err
info(line)
click to toggle source
Adds the line plus a newline
# File lib/ultra_marathon/logger.rb, line 11 def info(line) return if line.empty? log_string << padded_line(line) end
Private Instance Methods
log_formatted_error(error)
click to toggle source
# File lib/ultra_marathon/logger.rb, line 53 def log_formatted_error(error) info error.message formatted_backtrace = error.backtrace.map.with_index do |backtrace_line, line_number| sprintf('%03i) %s', line_number + 1, backtrace_line) end info formatted_backtrace.join(NEW_LINE) end
log_string()
click to toggle source
Private Instance Methods
# File lib/ultra_marathon/logger.rb, line 41 def log_string @log_string ||= '' end
padded_line(line)
click to toggle source
# File lib/ultra_marathon/logger.rb, line 45 def padded_line(line) if line.end_with? NEW_LINE line else line << NEW_LINE end end