Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ignore socket errors even if logger is not set.

Closes #2
  • Loading branch information...
commit fecfbc5acd2975b7ca99137612c00ddace2ce202 1 parent 9c15b2b
@j-manu authored jeremy committed
Showing with 6 additions and 22 deletions.
  1. +6 −22 lib/statsd.rb
View
28 lib/statsd.rb
@@ -25,14 +25,7 @@ class Statsd
class << self
# Set to a standard logger instance to enable debug logging.
- attr_reader :logger
-
- def logger=(logger) #:nodoc:
- @logger = logger
-
- # Only include logging behavior if a logger is set.
- include Logging
- end
+ attr_accessor :logger
end
# @param [String] host your statsd host
@@ -136,19 +129,10 @@ def send_stats(stat, delta, type, sample_rate=1)
end
end
- module Sending
- def send_to_socket(message)
- @socket.send(message, 0, @host, @port)
- end
- end
- include Sending
-
- module Logging
- def send_to_socket(message)
- self.class.logger.debug {"Statsd: #{message}"}
- super
- rescue => boom
- self.class.logger.error {"Statsd: #{boom.class} #{boom}"}
- end
+ def send_to_socket(message)
+ self.class.logger.debug { "Statsd: #{message}" } if self.class.logger
+ @socket.send(message, 0, @host, @port)
+ rescue => boom
+ self.class.logger.error { "Statsd: #{boom.class} #{boom}" } if self.class.logger
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.