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
debug(line)
Alias for: info
emerg(line)
Also aliased as: panic
Alias for: info
err(error)
Alias for: error
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
Also aliased as: emerg, warning, notice, debug
notice(line)
Alias for: info
panic(line)
Alias for: emerg
warn(line)
Alias for: warning
warning(line)
Also aliased as: warn
Alias for: info

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