lib/vedeu/support/log.rb in vedeu-0.4.37 vs lib/vedeu/support/log.rb in vedeu-0.4.38

- old
+ new

@@ -95,12 +95,15 @@ # @param type [Symbol] Colour code messages in the log file depending # on their source. # # @return [TrueClass] def log(message:, force: false, type: :info) - logger.debug([message_type(type), - message_body(type, message)]) if enabled? || force + output = [message_type(type), message_body(type, message)] + + logger.debug(output) if enabled? || force + + output end # @return [TrueClass] def log_stdout(type: :info, message:) $stdout.puts [message_type(type), message_body(type, message)].join @@ -109,21 +112,21 @@ # @return [TrueClass] def log_stderr(type: :info, message:) $stderr.puts [message_type(type), message_body(type, message)].join end + private + # @return [TrueClass] def logger MonoLogger.new(log_file).tap do |log| log.formatter = proc do |_, _, _, message| formatted_message(message) end end end - private - # @param message [String] # @return [String] def formatted_message(message) [timestamp, message, "\n"].join end @@ -181,10 +184,10 @@ unless @last == @time @time += (@now - @last).round(4) @last = @now end - "[#{format(@time.to_s, '%7.4f')}] ".rjust(7) + "[#{format('%7.4f', @time.to_s)}] ".rjust(7) end end # Log eigenclass end # Log