class SumologicCloudSyslog::Message

Message represents full message that can be sent to syslog

Attributes

header[RW]
msg[RW]
structured_data[RW]

Public Class Methods

new() click to toggle source
# File lib/sumologic_cloud_syslog/protocol.rb, line 113
def initialize
  @msg = ''
  @structured_data = []
  @header = Header.new
end

Public Instance Methods

assemble() click to toggle source
# File lib/sumologic_cloud_syslog/protocol.rb, line 119
def assemble
  # Start with header
  out = [header.to_s]
  # Add all structured data
  if structured_data.length > 0
    out << structured_data.map(&:to_s).join('')
  else
    out << SumologicCloudSyslog::NIL_VALUE
  end
  # Add message
  out << msg if msg.length > 0
  # Message must end with new line delimiter
  out.join(' ') + "\n"
end
to_s() click to toggle source
# File lib/sumologic_cloud_syslog/protocol.rb, line 134
def to_s
  assemble
end