From d65daad76eb8df2b909b65fbac49c8c8b5e7d097 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Wed, 8 Sep 2010 13:32:02 +1000 Subject: [PATCH] Fixed broken UDP logging format, field 1 is the local FQDN not the vhost --- lib/udp_logger.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/udp_logger.rb b/lib/udp_logger.rb index 079173a..4686c07 100644 --- a/lib/udp_logger.rb +++ b/lib/udp_logger.rb @@ -5,6 +5,7 @@ def initialize(app) @request_count = 0 @app = app @sock = UDPSocket.open + @hostname = `hostname --fqdn`.chomp end def deferred?(env) @@ -19,11 +20,11 @@ def call(env) req = Rack::Request.new(env) content_type = headers['Content-Type'] ? headers['Content-Type'].split(";").first : '-' timestamp = start.getutc.iso8601(2)[0..-2] - datagram = "#{req.port}.#{req.host} #{@request_count} #{timestamp} #{took} #{req.ip} TCP_MISS/#{status} #{body.size + headers.size} #{req.request_method.upcase} #{req.url} NONE/- #{content_type} #{env['HTTP_REFERRER'] || '-'} #{env['X-Forwarded-For'] || '-'} #{URI::encode(env['HTTP_USER_AGENT'] || '')}" + datagram = "#{@hostname} #{@request_count} #{timestamp} #{took} #{req.ip} TCP_MISS/#{status} #{body.size + headers.size} #{req.request_method.upcase} #{req.url} NONE/- #{content_type} #{env['HTTP_REFERRER'] || '-'} #{env['X-Forwarded-For'] || '-'} #{URI::encode(env['HTTP_USER_AGENT'] || '')}" @sock.send(datagram, 0, "208.80.152.138", 8420) [status, headers, body] end end -end \ No newline at end of file +end