Skip to content
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

Improve empty short_message identification #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion lib/fluent/gelf_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def make_gelfentry(tag,time,record, conf = {})
end
end

if !gelfentry.key?('short_message') or gelfentry['short_message'].to_s.empty? then
if !gelfentry.key?('short_message') or gelfentry['short_message'].to_s.empty? or gelfentry['short_message'].to_s.strip.empty? then
vasrem marked this conversation as resolved.
Show resolved Hide resolved
# allow other non-empty fields to masquerade as the short_message if it is unset
if gelfentry.key?('_message') and !gelfentry['_message'].to_s.empty? then
gelfentry['short_message'] = gelfentry.delete('_message')
Expand Down
8 changes: 8 additions & 0 deletions test/plugin/test_out_gelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ def test_format
d.run
end

def test_empty_short_message
d = create_driver
time = Time.now
d.emit({"short_message" => "\n\r \n"}, time.to_i)
d.expect_format({'_tag' => 'test', 'timestamp' => time.to_i, 'short_message' => '(no message)'}.to_msgpack)
d.run
end

def test_write
d = create_driver
time = Time.now
Expand Down