class Fluent::Plugin::Base

def string_safe_encoding(str)

def string_safe_encoding(str)
  unless str.valid_encoding?
    log.info "invalid byte sequence is replaced in `#{str}`" if self.respond_to?(:log)
    str = str.scrub('?')
  end
  yield str
end