cfoundry 0.3.34 → 0.3.35
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cfoundry/baseclient.rb +21 -0
- data/lib/cfoundry/v2/app.rb +7 -1
- data/lib/cfoundry/v2/model.rb +1 -1
- data/lib/cfoundry/version.rb +1 -1
- metadata +4 -4
data/lib/cfoundry/baseclient.rb
CHANGED
@@ -3,6 +3,9 @@ require "multi_json"
|
|
3
3
|
|
4
4
|
module CFoundry
|
5
5
|
class BaseClient # :nodoc:
|
6
|
+
LOG_FILE = File.expand_path("~/.cfoundry.log")
|
7
|
+
LOG_LENGTH = 10
|
8
|
+
|
6
9
|
attr_accessor :trace, :no_backtrace
|
7
10
|
|
8
11
|
def initialize(target, token = nil)
|
@@ -97,6 +100,7 @@ module CFoundry
|
|
97
100
|
|
98
101
|
RestClient::Request.execute(req) do |response, request|
|
99
102
|
print_trace(req, request, response, caller) if @trace
|
103
|
+
log_request(req, response)
|
100
104
|
handle_response(response, accept)
|
101
105
|
end
|
102
106
|
rescue SocketError, Errno::ECONNREFUSED => e
|
@@ -164,6 +168,23 @@ module CFoundry
|
|
164
168
|
}.join("/")
|
165
169
|
end
|
166
170
|
|
171
|
+
def log_request(req, response)
|
172
|
+
file = File.expand_path(LOG_FILE)
|
173
|
+
|
174
|
+
if File.exists?(file)
|
175
|
+
log = File.readlines(file).last(LOG_LENGTH - 1)
|
176
|
+
end
|
177
|
+
|
178
|
+
File.open(file, "w") do |io|
|
179
|
+
log.each { |l| io.print l } if log
|
180
|
+
io.puts log_line(req, response.headers[:x_vcap_request_id])
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def log_line(req, id)
|
185
|
+
"#{Time.now.strftime("%F %T")} #{id} #{req[:method].to_s.upcase.ljust(6)} #{req[:url]}"
|
186
|
+
end
|
187
|
+
|
167
188
|
def print_trace(req, request, response, locs)
|
168
189
|
$stderr.puts ">>>"
|
169
190
|
$stderr.puts "PROXY: #{RestClient.proxy}" if RestClient.proxy
|
data/lib/cfoundry/v2/app.rb
CHANGED
data/lib/cfoundry/v2/model.rb
CHANGED
data/lib/cfoundry/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 85
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 35
|
10
|
+
version: 0.3.35
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-26 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rest-client
|