lib/log_sanity/formatter.rb
# tags are ignored when rendering as json
# however, tags are prepended when rendering with string_formatter
tags are ignored when rendering as json
however, tags are prepended when rendering with string_formatter
tags are ignored when rendering as json however tags are prepended when rendering with string_formatter
def call(severity, timestamp, progname, msg)
      if msg.is_a? Hash
        msg.reverse_merge!('at' => timestamp) unless msg.key?('at')
      elsif msg.is_a? String
        if string_formatter
          msg = "#{tags_text}#{msg}" if current_tags.any?
          return string_formatter.call(severity, timestamp, progname, msg)
        else
          msg = {'at' => timestamp, 'message' => msg}
        end
      else
        msg = {'at' => timestamp, 'object' => msg.inspect}
      end
      if msg['at'].is_a? Float
        monot = Process.clock_gettime(Process::CLOCK_MONOTONIC)
        msg['at'] = Time.now - (monot - msg['at'])
      end
      msg['at'] = msg['at'].utc
      "#{msg.to_json}\n"
    end
def call ( severity , timestamp , progname , msg ) if msg . is_a? Hash msg . reverse_merge! ( 'at' => timestamp ) unless msg . key? ( 'at' ) elsif msg . is_a? String if string_formatter msg = "#{tags_text}#{msg}" if current_tags . any? return string_formatter . call ( severity , timestamp , progname , msg ) else msg = { 'at' => timestamp , 'message' => msg } end else msg = { 'at' => timestamp , 'object' => msg . inspect } end if msg [ 'at' ] . is_a? Float monot = Process . clock_gettime ( Process :: CLOCK_MONOTONIC ) msg [ 'at' ] = Time . now - ( monot - msg [ 'at' ] ) end msg [ 'at' ] = msg [ 'at' ] . utc "#{msg.to_json}\n" end
tags are ignored when rendering as json
however, tags are prepended when rendering with string_formatter
tags are ignored when rendering as json however tags are prepended when rendering with string_formatter
severity
<not_specific>
timestamp
<not_specific>
progname
<not_specific>
msg
<not_specific>