lib/terraspace/logger.rb in terraspace-0.2.4 vs lib/terraspace/logger.rb in terraspace-0.3.0

- old
+ new

@@ -1,26 +1,14 @@ require 'logger' module Terraspace class Logger < ::Logger - # Only need to override the add method as the other calls all lead to it. - def add(severity, message = nil, progname = nil) - # Taken from Logger#add source - # https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add - if message.nil? - if block_given? - message = yield - else - message = progname - progname = @progname - end + def format_message(severity, datetime, progname, msg) + line = if @logdev.dev == $stdout || @logdev.dev == $stderr + msg # super simple format if stdout + else + super # use the configured formatter end - - super # original logic - end - - # plain formatting - def format_message(severity, timestamp, progname, msg) - "#{msg}\n" + line =~ /\n$/ ? line : "#{line}\n" end end end