Skip to content

Commit

Permalink
Fixed broken UDP logging format, field 1 is the local FQDN not the vhost
Browse files Browse the repository at this point in the history
  • Loading branch information
tstarling committed Sep 8, 2010
1 parent 4b917c8 commit d65daad
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/udp_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def initialize(app)
@request_count = 0
@app = app
@sock = UDPSocket.open
@hostname = `hostname --fqdn`.chomp
end

def deferred?(env)
Expand All @@ -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
end

0 comments on commit d65daad

Please sign in to comment.