Sha256: d642a7f246b3790a80029ca813f1355a7df026611a1c1ee4846381c49ab729cf

Contents?: true

Size: 1.87 KB

Versions: 46

Compression:

Stored size: 1.87 KB

Contents

require 'gelf'

graylog_server = Rubber.instances.for_role('graylog_server').first

if graylog_server

  class MultiLogger
    def initialize(*objects)
      @objects = objects
    end

    def method_missing(*args)
      @objects.each {|o| o.send(*args) }
    end
  end
  
  gelf_logger = GELF::Logger.new(graylog_server.full_name,
                                 Rubber.config.graylog_server_port,
                                 'LAN',
                                 'facility' => 'rails',
                                 'host' => Rubber.config.host)
  Rails.logger = MultiLogger.new(Rails.logger, gelf_logger)

  # See https://github.com/Graylog2/graylog2_exceptions/wiki
  Rails.application.config.middleware.use "Graylog2Exceptions",
                                          {
                                            :hostname => graylog_server.full_name,
                                            :port => Rubber.config.graylog_server_port,
                                            :facility => "rails_exceptions",
                                            :local_app_name => Rubber.config.host,
                                            :level => GELF::FATAL,
                                            :max_chunk_size => 'LAN'
                                          }

  # Setup logging unhandled resque exceptions to graylog
  Graylog2::Resque::FailureHandler.configure do |config|
    config.gelf_server = graylog_server.full_name
    config.gelf_port = Rubber.config.graylog_server_port
    config.host = Rubber.config.host
    config.facility = "resque_exceptions"
    config.level = GELF::FATAL
    config.max_chunk_size = 'LAN'
  end
 
  require 'resque/failure/multiple'
  require 'resque/failure/redis'
  Resque::Failure::Multiple.classes = [
      Graylog2::Resque::FailureHandler,
      Resque::Failure::Redis
  ]
  Resque::Failure.backend = Resque::Failure::Multiple

end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
rubber-2.6.5 templates/graylog/config/initializers/graylog.rb
rubber-2.6.4 templates/graylog/config/initializers/graylog.rb
rubber-2.6.3 templates/graylog/config/initializers/graylog.rb
rubber-2.6.2 templates/graylog/config/initializers/graylog.rb
rubber-2.6.1 templates/graylog/config/initializers/graylog.rb
rubber-2.6.0 templates/graylog/config/initializers/graylog.rb
rubber-2.5.5 templates/graylog/config/initializers/graylog.rb
rubber-2.5.4 templates/graylog/config/initializers/graylog.rb
rubber-2.5.3 templates/graylog/config/initializers/graylog.rb
rubber-2.5.2 templates/graylog/config/initializers/graylog.rb
rubber-2.5.1 templates/graylog/config/initializers/graylog.rb
rubber-2.5.0 templates/graylog/config/initializers/graylog.rb
rubber-2.4.2 templates/graylog/config/initializers/graylog.rb
rubber-2.4.1 templates/graylog/config/initializers/graylog.rb
rubber-2.4.0 templates/graylog/config/initializers/graylog.rb
rubber-2.3.1 templates/graylog/config/initializers/graylog.rb
rubber-2.3.0 templates/graylog/config/initializers/graylog.rb
rubber-2.2.4 templates/graylog/config/initializers/graylog.rb
rubber-2.2.3 templates/graylog/config/initializers/graylog.rb
rubber-2.2.2 templates/graylog/config/initializers/graylog.rb