Sha256: de6405ec9b672ec4c3e3f86ba683af41306fc92c7b420465cd6947d5c484df81

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'socket'
require 'logger'
require 'benchmark'

module Metricsd
  class << self
    def server_host
      @@server_host
    end

    def server_host=(host)
      @@server_host = host
      Client.reset_connection!
    end

    def server_port
      @@server_port
    end

    def server_port=(port)
      @@server_port = Integer(port)
      Client.reset_connection!
    end

    def source
      @@source || metricsd.default_source
    end

    def source=(source)
      @@source = source
    end

    def default_source
      @@default_source
    end

    def default_source=(source)
      @@default_source = source
    end

    def logger
      @@logger ||= if defined?(Rails)
        Rails.logger
      elsif defined?(Loops)
        Loops.logger
      else
        Logger.new(STDOUT)
      end
    end

    def logger=(logger)
      @@logger = logger
    end

    def reset_defaults!
      @@server_host    = '127.0.0.1'
      @@server_port    = 6311
      @@source         = Socket.gethostname[/^([^.]+)/, 1]
      @@default_source = 'all'
      @@logger         = nil
    end
  end

  reset_defaults!
end

require 'metricsd/client'
require "metricsd/version"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
metricsd-0.1.0 lib/metricsd.rb