Sha256: 89615635ac6d783b18d55364c506a867fabd7ab60db1e77241a6ad8e372080e7
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
require "logstash/codecs/multiline" require "logstash/event" require "insist" describe LogStash::Codecs::Multiline do context "#decode" do it "should be able to handle multiline events with additional lines space-indented" do codec = LogStash::Codecs::Multiline.new("pattern" => "^\\s", "what" => "previous") lines = [ "hello world", " second line", "another first line" ] events = [] lines.each do |line| codec.decode(line) do |event| events << event end end codec.flush { |e| events << e } insist { events.size } == 2 insist { events[0]["message"] } == "hello world\n second line" insist { events[0]["tags"] }.include?("multiline") insist { events[1]["message"] } == "another first line" insist { events[1]["tags"] }.nil? end it "should allow custom tag added to multiline events" do codec = LogStash::Codecs::Multiline.new("pattern" => "^\\s", "what" => "previous", "multiline_tag" => "hurray" ) lines = [ "hello world", " second line", "another first line" ] events = [] lines.each do |line| codec.decode(line) do |event| events << event end end codec.flush { |e| events << e } insist { events.size } == 2 insist { events[0]["tags"] }.include?("hurray") insist { events[1]["tags"] }.nil? end it "should allow grok patterns to be used" do codec = LogStash::Codecs::Multiline.new( "pattern" => "^%{NUMBER} %{TIME}", "negate" => true, "what" => "previous" ) lines = [ "120913 12:04:33 first line", "second line", "third line" ] events = [] lines.each do |line| codec.decode(line) do |event| events << event end end codec.flush { |e| events << e } insist { events.size } == 1 insist { events.first["message"] } == lines.join("\n") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logstash-lib-1.3.2 | spec/codecs/multiline.rb |