Skip to content

enable the configuration of the line delimiter for the json output #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/logstash/codecs/json_lines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class LogStash::Codecs::JSONLines < LogStash::Codecs::Base
#
# For nxlog users, you'll want to set this to `CP1252`
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"

config :line_delimiter, :validate => :number

public
def initialize(params={})
super(params)
Expand All @@ -46,7 +47,11 @@ def decode(data)
def encode(event)
# Tack on a \n for now because previously most of logstash's JSON
# outputs emitted one per line, and whitespace is OK in json.
@on_event.call(event, event.to_json + NL)
if @line_delimiter != nil
@on_event.call(event, event.to_json + @line_delimiter.chr)
else
@on_event.call(event, event.to_json + NL)
end
end # def encode

end # class LogStash::Codecs::JSON