class SmartLoggerWrapper::Options::To

Public Instance Methods

apply!(messages, arguments, severity, wrapper) click to toggle source
# File lib/smart_logger_wrapper/options/to.rb, line 7
def apply!(messages, arguments, severity, wrapper)
  raise ApplicationError, 'No handler given' if arguments.empty?
  out = arguments.first
  time = Time.now
  severity_label = wrapper.format_severity(severity)
  out.puts messages.map { |message| wrapper.format_message(severity_label, time, nil, message) }.join("\n")
rescue NoMethodError => e
  raise ApplicationError, e.message
end