vendor/bundle/ruby/2.6.0/gems/lumberjack-1.2.8/lib/lumberjack/template.rb
# Convert an entry into a string using the template.
Convert an entry into a string using the template.
Convert an entry into a string using the template .
def call(entry)
      return entry unless entry.is_a?(LogEntry)
      first_line = entry.message.to_s
      additional_lines = nil
      if first_line.include?(Lumberjack::LINE_SEPARATOR)
        additional_lines = first_line.split(Lumberjack::LINE_SEPARATOR)
        first_line = additional_lines.shift
      end
      formatted_time = @time_formatter.call(entry.time) if @template_include_time
      format_args = [formatted_time, entry.severity_label, entry.progname, entry.pid, first_line]
      tag_arguments = tag_args(entry.tags, @first_line_tags)
      message = (@first_line_template % (format_args + tag_arguments))
      message.rstrip! if message.end_with?(" ")
      if additional_lines && !additional_lines.empty?
        tag_arguments = tag_args(entry.tags, @additional_line_tags) unless @additional_line_tags == @first_line_tags
        additional_lines.each do |line|
          format_args[format_args.size - 1] = line
          line_message = (@additional_line_template % (format_args + tag_arguments)).rstrip
          line_message.rstrip! if line_message.end_with?(" ")
          message << line_message
        end
      end
      message
    end
def call ( entry ) return entry unless entry . is_a? ( LogEntry ) first_line = entry . message . to_s additional_lines = nil if first_line . include? ( Lumberjack :: LINE_SEPARATOR ) additional_lines = first_line . split ( Lumberjack :: LINE_SEPARATOR ) first_line = additional_lines . shift end formatted_time = @time_formatter . call ( entry . time ) if @template_include_time format_args = [ formatted_time , entry . severity_label , entry . progname , entry . pid , first_line ] tag_arguments = tag_args ( entry . tags , @first_line_tags ) message = ( @first_line_template % ( format_args + tag_arguments ) ) message . rstrip! if message . end_with? ( " " ) if additional_lines && ! additional_lines . empty? tag_arguments = tag_args ( entry . tags , @additional_line_tags ) unless @additional_line_tags == @first_line_tags additional_lines . each do | line | format_args [ format_args . size - 1 ] = line line_message = ( @additional_line_template % ( format_args + tag_arguments ) ) . rstrip line_message . rstrip! if line_message . end_with? ( " " ) message << line_message end end message end
Convert an entry into a string using the template.
Convert an entry into a string using the template .
entry