Sha256: fcc3eecb5e306d41f09a3323fbffc2a38babf568936a6fe092acaa764fdc611b

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

require 'bugsnag'
require 'bugsnag/delivery'
require 'bugsnag/delivery/fluent/version'
require 'fluent-logger'

module Bugsnag
  module FluentConfiguration
    def self.included(klass)
      klass.class_eval do
        attr_accessor :fluent_tag_prefix
        attr_accessor :fluent_host
        attr_accessor :fluent_port
      end
      Bugsnag.configuration.fluent_tag_prefix = 'bugsnag'
      Bugsnag.configuration.fluent_host = 'localhost'
      Bugsnag.configuration.fluent_port = 24224
    end
  end

  class Configuration
    include FluentConfiguration
  end

  module Delivery
    class Fluent
      def self.deliver(url, body, configuration)
        logger = ::Fluent::Logger::FluentLogger.new(
          configuration.fluent_tag_prefix,
          :host => configuration.fluent_host,
          :port => configuration.fluent_port
        )
        unless logger.post('deliver', { :url => url, :body => body })
          configuration.logger.error logger.last_error
        end
      end
    end
  end
end

Bugsnag::Delivery.register(:fluent, Bugsnag::Delivery::Fluent)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bugsnag-delivery-fluent-0.1.0 lib/bugsnag/delivery/fluent.rb