1919require 'fluent/plugin/storage'
2020
2121require 'fileutils'
22- require 'yajl '
22+ require 'json '
2323
2424module Fluent
2525 module Plugin
@@ -90,7 +90,7 @@ def configure(conf)
9090 log . warn "detect empty plugin storage file during startup. Ignored: #{ @path } "
9191 return
9292 end
93- data = Yajl :: Parser . parse ( data )
93+ data = JSON . parse ( data )
9494 raise Fluent ::ConfigError , "Invalid contents (not object) in plugin storage file: '#{ @path } '" unless data . is_a? ( Hash )
9595 rescue => e
9696 log . error "failed to read data from plugin storage file" , path : @path , error : e
@@ -114,7 +114,7 @@ def load
114114 return unless File . exist? ( @path )
115115 begin
116116 json_string = File . open ( @path , 'r:utf-8' ) { |io | io . read }
117- json = Yajl :: Parser . parse ( json_string )
117+ json = JSON . parse ( json_string )
118118 unless json . is_a? ( Hash )
119119 log . error "broken content for plugin storage (Hash required: ignored)" , type : json . class
120120 log . debug "broken content" , content : json_string
@@ -130,7 +130,11 @@ def save
130130 return if @on_memory
131131 tmp_path = @path + '.tmp.' + Fluent ::UniqueId . hex ( Fluent ::UniqueId . generate )
132132 begin
133- json_string = Yajl ::Encoder . encode ( @store , pretty : @pretty_print )
133+ if @pretty_print
134+ json_string = JSON . pretty_generate ( @store )
135+ else
136+ json_string = JSON . generate ( @store )
137+ end
134138 File . open ( tmp_path , 'w:utf-8' , @mode ) { |io | io . write json_string ; io . fsync }
135139 File . rename ( tmp_path , @path )
136140 rescue => e
0 commit comments