Sha256: 653d5e3dd384b077da6635c464f613dae9dd596c8a2eff852e3c50b82f79e227
Contents?: true
Size: 731 Bytes
Versions: 2
Compression:
Stored size: 731 Bytes
Contents
module PushyDaemon class Formatter def self.call severity, datetime, progname, payload # Build common values timestamp = datetime.strftime(LOG_FORMAT_TIME) # Build header header = sprintf LOG_FORMAT_HEADER, 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_TRIM_LINE].force_encoding(Encoding::UTF_8) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pushyd-0.5.3 | lib/pushyd/formatter.rb |
pushyd-0.5.2 | lib/pushyd/formatter.rb |