Sha256: a40d69e402ce0853bb0b55c312ee3a5ca8d07a6dcca5980cf783b45c1a5c2611
Contents?: true
Size: 741 Bytes
Versions: 14
Compression:
Stored size: 741 Bytes
Contents
module BmcDaemonLib class LoggerFormatter def self.call severity, datetime, progname, payload # Build common values timestamp = datetime.strftime(LOG_HEADER_TIME) # Build header header = sprintf LOG_HEADER_FORMAT, timestamp, Process.pid, severity, progname # If we have a bunch of lines, prefix them and send them together return payload.map do |line| "#{header}#{trimmed(line)}\n" end.join if payload.is_a?(Array) # Otherwise, just prefix the only line return "#{header}#{trimmed(payload)}\n" end protected def self.trimmed line line.to_s.rstrip[0..LOG_MESSAGE_TRIM].force_encoding(Encoding::UTF_8) end end end
Version data entries
14 entries across 14 versions & 1 rubygems