diff --git a/gelf.gemspec b/gelf.gemspec index 34e56e8..654a47a 100644 --- a/gelf.gemspec +++ b/gelf.gemspec @@ -59,6 +59,7 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, ["~> 1.1.0"]) s.add_development_dependency(%q, ["~> 3.2.0"]) s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, ["~> 1.0"]) else s.add_dependency(%q, ["~> 2.11.3"]) s.add_dependency(%q, ["~> 2.1.1"]) @@ -66,6 +67,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, ["~> 1.1.0"]) s.add_dependency(%q, ["~> 3.2.0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0"]) end else s.add_dependency(%q, ["~> 2.11.3"]) @@ -74,6 +76,7 @@ Gem::Specification.new do |s| s.add_dependency(%q, ["~> 1.1.0"]) s.add_dependency(%q, ["~> 3.2.0"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 1.0"]) end end diff --git a/lib/gelf/notifier.rb b/lib/gelf/notifier.rb index fcaf0de..8d1e2f9 100644 --- a/lib/gelf/notifier.rb +++ b/lib/gelf/notifier.rb @@ -2,11 +2,7 @@ require 'gelf/transport/tcp' require 'gelf/transport/tcp_tls' -# replace JSON and #to_json with Yajl if available -begin - require 'yajl/json_gem' -rescue LoadError -end +require 'multi_json' module GELF # Graylog2 notifier. @@ -163,7 +159,7 @@ def notify_with_level!(message_level, *args) if hash['level'] >= level if default_options['protocol'] == GELF::Protocol::TCP validate_hash(hash) - @sender.send(hash.to_json + "\0") + @sender.send(MultiJson.dump(hash) + "\0") else @sender.send_datagrams(datagrams_from_hash(hash)) end @@ -260,7 +256,7 @@ def validate_hash(hash) def serialize_hash(hash) validate_hash(hash) - Zlib::Deflate.deflate(hash.to_json).bytes + Zlib::Deflate.deflate(MultiJson.dump(hash)).bytes end def self.stringify_keys(data)