Module: MultiStatsd
- Defined in:
- lib/multi-statsd.rb,
lib/multi-statsd/server.rb,
lib/multi-statsd/version.rb,
lib/multi-statsd/backends/base.rb
Overview
MultiStatsd namespace
Defined Under Namespace
Modules: Backend Classes: Server
Constant Summary collapse
- VERSION =
Gem version
"0.0.1"
Class Method Summary collapse
-
.logger ⇒ Logger
Return the logger.
-
.logger=(logger) ⇒ Object
Assign a logger.
-
.start(options) ⇒ thread
Start up the Eventmachine reactor loop in a separate thread give a set of options.
-
.stop ⇒ Object
Stop the Eventmachine reactor loop.
Class Method Details
.logger ⇒ Logger
Return the logger
19 20 21 22 23 24 |
# File 'lib/multi-statsd.rb', line 19 def self.logger return @logger if defined?(@logger) log = Logger.new(STDOUT) log.level = 2 @logger = EM::Logger.new(log) end |
.logger=(logger) ⇒ Object
Assign a logger
13 14 15 |
# File 'lib/multi-statsd.rb', line 13 def self.logger=(logger) @logger = logger.kind_of?(EM::Logger) ? logger : EM::Logger.new(logger) end |
.start(options) ⇒ thread
Start up the Eventmachine reactor loop in a separate thread give a set of options.
This is a test
This is another test
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/multi-statsd.rb', line 31 def self.start() thread = Thread.new do EM.run do backends = [] ['backends'].each_pair do |name, | backend = .delete('backend') begin require "multi-statsd/backends/#{backend.downcase}" rescue LoadError raise MultiStatsd::Backend::Error, "Cannot load file multi-statsd/backends/#{backend.downcase}" end if !MultiStatsd::Backend.const_defined?(backend) raise MultiStatsd::Backend::Error, "No such back end: MultiStatsd::Backend::#{backend}" else logger.info "Adding backend #{backend} :: #{name}" backends << MultiStatsd::Backend.const_get(backend).new(name, ) end end EM::open_datagram_socket( (['host'] || '127.0.0.1'), (['port'] || 8125), MultiStatsd::Server, backends ) logger.info "multi-statsd starting up on #{['host']}:#{['port']}" end end thread.abort_on_exception = true thread end |
.stop ⇒ Object
Stop the Eventmachine reactor loop
65 66 67 68 |
# File 'lib/multi-statsd.rb', line 65 def self.stop logger.info "multi-statsd shutting down" EM.next_tick { EM.stop } end |