Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore socket errors always #2

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 6 additions & 22 deletions lib/statsd.rb
Expand Up @@ -24,14 +24,7 @@ class Statsd


class << self class << self
# Set to a standard logger instance to enable debug logging. # Set to a standard logger instance to enable debug logging.
attr_reader :logger attr_accessor :logger

def logger=(logger) #:nodoc:
@logger = logger

# Only include logging behavior if a logger is set.
include Logging
end
end end


# @param [String] host your statsd host # @param [String] host your statsd host
Expand Down Expand Up @@ -135,19 +128,10 @@ def send_stats(stat, delta, type, sample_rate=1)
end end
end end


module Sending def send_to_socket(message)
def send_to_socket(message) self.class.logger.debug {"Statsd: #{message}"} if self.class.logger
@socket.send(message, 0, @host, @port) @socket.send(message, 0, @host, @port)
end rescue => boom
end self.class.logger.error {"Statsd: #{boom.class} #{boom}"} if self.class.logge
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
end end
end end