Class: Gelfd::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/gelfd/parser.rb

Class Method Summary collapse

Class Method Details

.parse(data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gelfd/parser.rb', line 4

def self.parse(data)
  header = data[0..1]
  case header
  when ZLIB_MAGIC
    ZlibParser.parse(data)
  when CHUNKED_MAGIC
    ChunkedParser.parse(data)
  when GZIP_MAGIC
    GzipParser.parse(data)
  else
    raise UnknownHeaderError, "Could not find parser for header: #{header.unpack('C*').to_s}"
  end
end