nice_http 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nice_http.rb +17 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7cbcfe83c29ee5c4c0541c2ae1f3d15bff05b0c095d13c56311aecc766afe3cb
4
- data.tar.gz: 7db1a2fcf6e53866084e95bba2091da34ff348018ac325d8206135a75902fb75
3
+ metadata.gz: 052b542a148c8c37dca6aa1a0811fd5fc5b3444f652622c9225201f8127c6560
4
+ data.tar.gz: a3f7b33c38d4e4950c87d1925980a7598f11d4777926bd66e0ff9be6f4f9bcd6
5
5
  SHA512:
6
- metadata.gz: fb10558757d505fd32a99128999acde3cef5e4848d5a9da3584103102e7ee818a40d748f469120b979be10c2460bc58d6b9ad73e65f751ea847ef0bd289bf471
7
- data.tar.gz: 67ff0bad4cc079954ee525bbc090859554abdf652d347b708665c58d26192ac07dc4f1b1d4499b8949d555925c478355ff436ef4279fecd48213febd3688931c
6
+ metadata.gz: d018a84c812d9667a7b9677e330155b579515bbc8fe70131203954b25be247aacf7f8fe30db0cf6ff9f2a46c2a7a4c7d77d7267df76c68c1ef24af77dd0d5c98
7
+ data.tar.gz: e11baceaedbfd53baf36b38df93352dec79fe2d2ea4d4cf151a6c799afdbfab720f1f7ece5e31539d8b2949fe4b8c5ebc703e227996c1aaef1177dfcb84c9ac4
data/lib/nice_http.rb CHANGED
@@ -55,7 +55,7 @@ class NiceHttp
55
55
  class << self
56
56
  attr_accessor :host, :port, :ssl, :headers, :debug, :log, :proxy_host, :proxy_port,
57
57
  :last_request, :last_response, :request_id, :use_mocks, :connections,
58
- :active, :auto_redirect
58
+ :active, :auto_redirect, :log_files
59
59
  end
60
60
 
61
61
  ######################################################
@@ -77,6 +77,7 @@ class NiceHttp
77
77
  @connections = []
78
78
  @active = 0
79
79
  @auto_redirect = true
80
+ @log_files = []
80
81
  end
81
82
  reset!
82
83
 
@@ -193,22 +194,27 @@ class NiceHttp
193
194
  end
194
195
 
195
196
  begin
196
- #only the first connection in the run will be deleting
197
- if self.class.last_request.nil?
198
- mode = "w"
199
- else
200
- mode = "a"
201
- end
197
+ mode = "a"
198
+ log_filename =''
202
199
  if @log.kind_of?(String)
203
- f = File.new(@log, mode)
200
+ #only the first connection in the run will be deleting the log file
201
+ log_filename = @log
202
+ mode = "w" unless self.class.log_files.include?(log_filename)
203
+ f = File.new(log_filename, mode)
204
204
  f.sync = true
205
205
  @logger = Logger.new f
206
206
  elsif @log == :fix_file
207
- f = File.new("nice_http.log", mode)
207
+ #only the first connection in the run will be deleting the log file
208
+ log_filename = 'nice_http.log'
209
+ mode = "w" unless self.class.log_files.include?(log_filename)
210
+ f = File.new(log_filename, mode)
208
211
  f.sync = true
209
212
  @logger = Logger.new f
210
213
  elsif @log == :file
211
- f = File.new("nice_http_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.log", mode)
214
+ log_filename = "nice_http_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.log"
215
+ #only the first connection in the run will be deleting the log file
216
+ mode = "w" unless self.class.log_files.include?(log_filename)
217
+ f = File.new(log_filename, mode)
212
218
  f.sync = true
213
219
  @logger = Logger.new f
214
220
  elsif @log == :screen
@@ -219,6 +225,7 @@ class NiceHttp
219
225
  raise InfoMissing, :log
220
226
  end
221
227
  @logger.level = Logger::INFO
228
+ self.class.log_files << log_filename if mode == 'w'
222
229
  rescue Exception => stack
223
230
  raise InfoMissing, :log
224
231
  @logger = Logger.new nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz