Sha256: aaae243541c982a6023c5cb8b2bea7b63299983046393162c79c1803bfa4511d

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

require 'fluent/formatter'

module Fluent
  module TextFormatter
    class GELFFormatter < Formatter

      unless method_defined?(:log)
        define_method('log') { $log }
      end

      Plugin.register_formatter("gelf", self)

      require 'fluent/gelf_util'
      include GelfUtil

      config_param :use_record_host, :bool, :default => true
      config_param :add_msec_time, :bool, :default => false

      def configure(conf)
        super(conf)
      end

      def format(tag, time, record)

        begin

          gelfentry = make_gelfentry(
            tag,time,record,
            {
              :use_record_host => @use_record_host,
              :add_msec_time => @add_msec_time
            }
          )

          make_json(gelfentry,{})
      
        rescue Exception => e
          log.error sprintf(
            'Error trying to serialize %s: %s',
            record.to_s.force_encoding('UTF-8'),
            e.message.to_s.force_encoding('UTF-8')
          )
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
fluent-plugin-gelf-out.fitterpen-1.0.4 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-out.fitterpen-1.0.3 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-better-1.0.3 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-hs-1.0.8 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-hs-1.0.7 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-hs-1.0.6 lib/fluent/plugin/formatter_gelf.rb
fluent-plugin-gelf-hs-1.0.5 lib/fluent/plugin/formatter_gelf.rb