Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions lib/fluent/command/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
end

require 'socket'
require 'yajl'
require 'json'
require 'msgpack'
require 'fluent/ext_monitor_require'

Expand Down Expand Up @@ -304,7 +304,7 @@ def try_connect
end

def abort_message(time, record)
$stdout.puts "!#{time}:#{Yajl.dump(record)}"
$stdout.puts "!#{time}:#{JSON.generate(record)}"
end
end

Expand All @@ -326,7 +326,7 @@ def abort_message(time, record)
when 'json'
begin
while line = $stdin.gets
record = Yajl.load(line)
record = JSON.parse(line)
w.write(record)
end
rescue
Expand Down
3 changes: 2 additions & 1 deletion lib/fluent/compat/exec_util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#

require 'msgpack'
require 'json'
require 'yajl'

require 'fluent/engine'
Expand Down Expand Up @@ -115,7 +116,7 @@ def call(record, out)

class JSONFormatter < Formatter
def call(record, out)
out << Yajl.dump(record) << "\n"
out << JSON.generate(record) << "\n"
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def format=(fmt)
if wid = get_worker_id(type)
r['worker_id'] = wid
end
Yajl.dump(r)
JSON.generate(r)
}
end

Expand Down Expand Up @@ -554,7 +554,7 @@ def dump_stacktrace_internal(type, backtrace, level)
Thread.current[:last_repeated_stacktrace] = CachedLog.new(backtrace, time) if @suppress_repeated_stacktrace
end

puts Yajl.dump(r)
puts JSON.generate(r)
end

nil
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

require 'fluent/plugin/input'
require 'yajl'
require 'json'

module Fluent::Plugin
class ExecInput < Fluent::Plugin::Input
Expand Down Expand Up @@ -115,7 +115,7 @@ def on_record(time, record)
time ||= extract_time_from_record(record) || Fluent::EventTime.now
router.emit(tag, time, record)
rescue => e
log.error "exec failed to emit", tag: tag, record: Yajl.dump(record), error: e
log.error "exec failed to emit", tag: tag, record: JSON.generate(record), error: e
router.emit_error_event(tag, time, record, e) if tag && time && record
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_object_space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

require 'yajl'
require 'json'

require 'fluent/plugin/input'

Expand Down Expand Up @@ -86,7 +86,7 @@ def on_timer

router.emit(@tag, now, record)
rescue => e
log.error "object space failed to emit", error: e, tag: @tag, record: Yajl.dump(record)
log.error "object space failed to emit", error: e, tag: @tag, record: JSON.generate(record)
log.error_backtrace
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/in_syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
require 'fluent/config/error'
require 'fluent/plugin/parser'

require 'yajl'
require 'json'

module Fluent::Plugin
class SyslogInput < Input
Expand Down Expand Up @@ -274,7 +274,7 @@ def message_handler(data, sock)
def emit(tag, time, record)
router.emit(tag, time, record)
rescue => e
log.error "syslog failed to emit", error: e, tag: tag, record: Yajl.dump(record)
log.error "syslog failed to emit", error: e, tag: tag, record: JSON.generate(record)
end
end
end
4 changes: 2 additions & 2 deletions lib/fluent/plugin/out_exec_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require 'fluent/env'
require 'fluent/config/error'

require 'yajl'
require 'json'

module Fluent::Plugin
class ExecFilterOutput < Output
Expand Down Expand Up @@ -309,7 +309,7 @@ def on_record(time, record)
router.emit(tag, time, record)
rescue => e
if @suppress_error_log_interval == 0 || Time.now.to_i > @next_log_time
log.error "exec_filter failed to emit", record: Yajl.dump(record), error: e
log.error "exec_filter failed to emit", record: JSON.generate(record), error: e
log.error_backtrace e.backtrace
@next_log_time = Time.now.to_i + @suppress_error_log_interval
end
Expand Down
14 changes: 7 additions & 7 deletions test/command/test_binlog_reader.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../helper'

require 'yajl'
require 'json'
require 'flexmock/test_unit'

require 'fluent/command/binlog_reader'
Expand Down Expand Up @@ -146,7 +146,7 @@ class TestHead < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
head = BinlogReaderCommand::Head.new(argv)
out = capture_stdout { head.call }
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 5, out
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{JSON.generate(@record)}#{@default_newline}" * 5, out
end
end

Expand All @@ -157,7 +157,7 @@ class TestHead < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
head = BinlogReaderCommand::Head.new(argv)
out = capture_stdout { head.call }
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{JSON.generate(@record)}#{@default_newline}", out
end
end

Expand All @@ -177,7 +177,7 @@ class TestHead < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
head = BinlogReaderCommand::Head.new(argv)
out = capture_stdout { head.call }
assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
assert_equal "#{JSON.generate(@record)}#{@default_newline}", out
end
end

Expand Down Expand Up @@ -270,7 +270,7 @@ class TestCat < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
head = BinlogReaderCommand::Cat.new(argv)
out = capture_stdout { head.call }
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}" * 6, out
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{JSON.generate(@record)}#{@default_newline}" * 6, out
end
end

Expand All @@ -281,7 +281,7 @@ class TestCat < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i] * 6, [@record] * 6)
head = BinlogReaderCommand::Cat.new(argv)
out = capture_stdout { head.call }
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{Yajl.dump(@record)}#{@default_newline}", out
assert_equal "2011-01-02T13:14:15+00:00\t#{TMP_DIR}/#{@file_name}\t#{JSON.generate(@record)}#{@default_newline}", out
end
end

Expand All @@ -292,7 +292,7 @@ class TestCat < TestBaseCommand
create_message_packed_file(@file_name, [event_time(@t).to_i], [@record])
head = BinlogReaderCommand::Cat.new(argv)
out = capture_stdout { head.call }
assert_equal "#{Yajl.dump(@record)}#{@default_newline}", out
assert_equal "#{JSON.generate(@record)}#{@default_newline}", out
end
end

Expand Down
1 change: 0 additions & 1 deletion test/command/test_ca_generate.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require_relative '../helper'

require 'yajl'
require 'flexmock/test_unit'
require 'tmpdir'

Expand Down
12 changes: 6 additions & 6 deletions test/plugin/test_formatter_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_configured_with_utc_or_localtime(data)
oldtz, ENV['TZ'] = ENV['TZ'], "UTC+07"
d = create_driver(config_element('ROOT', '', {key => value}))
tag = 'test'
assert_equal "#{expected}\t#{tag}\t#{Yajl.dump(record)}#{@default_newline}", d.instance.format(tag, time, record)
assert_equal "#{expected}\t#{tag}\t#{JSON.generate(record)}#{@default_newline}", d.instance.format(tag, time, record)
ensure
ENV['TZ'] = oldtz
end
Expand All @@ -66,7 +66,7 @@ def test_format(data)
d = create_driver({"newline" => newline_conf})
formatted = d.instance.format(tag, @time, record)

assert_equal("#{time2str(@time)}\t#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
assert_equal("#{time2str(@time)}\t#{tag}\t#{JSON.generate(record)}#{newline}", formatted)
end

data("newline (LF)" => ["lf", "\n"],
Expand All @@ -76,7 +76,7 @@ def test_format_without_time(data)
d = create_driver('output_time' => 'false', 'newline' => newline_conf)
formatted = d.instance.format(tag, @time, record)

assert_equal("#{tag}\t#{Yajl.dump(record)}#{newline}", formatted)
assert_equal("#{tag}\t#{JSON.generate(record)}#{newline}", formatted)
end

data("newline (LF)" => ["lf", "\n"],
Expand All @@ -86,7 +86,7 @@ def test_format_without_tag(data)
d = create_driver('output_tag' => 'false', 'newline' => newline_conf)
formatted = d.instance.format(tag, @time, record)

assert_equal("#{time2str(@time)}\t#{Yajl.dump(record)}#{newline}", formatted)
assert_equal("#{time2str(@time)}\t#{JSON.generate(record)}#{newline}", formatted)
end

data("newline (LF)" => ["lf", "\n"],
Expand All @@ -96,7 +96,7 @@ def test_format_without_time_and_tag
d = create_driver('output_tag' => 'false', 'output_time' => 'false', 'newline' => newline_conf)
formatted = d.instance.format('tag', @time, record)

assert_equal("#{Yajl.dump(record)}#{newline}", formatted)
assert_equal("#{JSON.generate(record)}#{newline}", formatted)
end

data("newline (LF)" => ["lf", "\n"],
Expand All @@ -111,6 +111,6 @@ def test_format_without_time_and_tag_against_string_literal_configure(data)
])
formatted = d.instance.format('tag', @time, record)

assert_equal("#{Yajl.dump(record)}#{newline}", formatted)
assert_equal("#{JSON.generate(record)}#{newline}", formatted)
end
end
4 changes: 2 additions & 2 deletions test/plugin/test_out_exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def create_test_data
d.feed(time, records[1])
end

assert_equal Yajl.dump(records[0]) + "\n", d.formatted[0]
assert_equal Yajl.dump(records[1]) + "\n", d.formatted[1]
assert_equal JSON.generate(records[0]) + "\n", d.formatted[0]
assert_equal JSON.generate(records[1]) + "\n", d.formatted[1]
end

data(
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def parse_system(text)
end

path = d.instance.last_written_path
check_zipped_result(path, %[#{Yajl.dump({"a" => 1, 'time' => time.to_i})}#{@default_newline}] + %[#{Yajl.dump({"a" => 2, 'time' => time.to_i})}#{@default_newline}])
check_zipped_result(path, %[#{JSON.generate({"a" => 1, 'time' => time.to_i})}#{@default_newline}] + %[#{JSON.generate({"a" => 2, 'time' => time.to_i})}#{@default_newline}])
end

test 'ltsv' do
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/test_parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_raise_exception_for_unknown_input
end
end

def test_fall_back_oj_to_yajl_if_oj_not_available
def test_fall_back_oj_to_json_if_oj_not_available
stub(Fluent::OjOptions).available? { false }

result = @parser.instance.configure_json_parser(:oj)
Expand Down
Loading