Permalink
Browse files

unify the log creation into a single place

Change-Id: Ie6a87f3aa56bfbb837244e3a006bc2c985f977ba
  • Loading branch information...
1 parent 5531c97 commit 03a79dd6ff7952529b2b6bd6d0e470fdc3ccd371 Patrick Bozeman committed Oct 21, 2011
Showing with 4 additions and 9 deletions.
  1. +4 −9 lib/caldecott/server/http_tunnel.rb
@@ -163,9 +163,10 @@ def tunnel_from_id(tun_id)
end
before do
+ @log = SessionLogger.new("server", STDOUT)
+ @log.debug "#{request.request_method} #{request.url}"
if env['HTTP_AUTH_TOKEN'] != settings.auth_token
- log = SessionLogger.new("server", STDOUT)
- log.debug "#{request.request_method} #{request.url} AUTH FAILURE #{env.inspect}"
+ @log.debug "AUTH FAILURE #{env.inspect}"
not_found
end
end
@@ -181,22 +182,16 @@ def tunnel_from_id(tun_id)
end
apost '/tunnels' do
- log = SessionLogger.new("server", STDOUT)
- log.debug "#{request.request_method} #{request.url}"
req = JSON.parse(request.body.read, :symbolize_names => true)
- Tunnel.new(log, @@tunnels, req[:host], req[:port]).open(self)
+ Tunnel.new(@log, @@tunnels, req[:host], req[:port]).open(self)
end
get '/tunnels/:tun' do |tun_id|
- log = SessionLogger.new("server", STDOUT)
- log.debug "#{request.request_method} #{request.url}"
tun = tunnel_from_id(tun_id)
tun.safe_hash.to_json
end
delete '/tunnels/:tun' do |tun_id|
- log = SessionLogger.new("server", STDOUT)
- log.debug "#{request.request_method} #{request.url}"
tun = tunnel_from_id(tun_id)
tun.delete
end

0 comments on commit 03a79dd

Please sign in to comment.