Skip to content

Commit

Permalink
log file will be deleted only on first run everytime
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioRuiz committed Feb 11, 2019
1 parent db8662d commit 0579c54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions lib/nice_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def self.reset!
@connections = []
@active = 0
@auto_redirect = true
@delete_log_file_content = true
end
reset!

Expand Down Expand Up @@ -193,16 +194,23 @@ def initialize(args = {})
end

begin
#only the first connection in the run will be deleting
if @delete_log_file_content
mode = "w"
@delete_log_file_content = false
else
mode = "a"
end
if @log.kind_of?(String)
f = File.new(@log, "w")
f = File.new(@log, mode)
f.sync = true
@logger = Logger.new f
elsif @log == :fix_file
f = File.new("nice_http.log", "w")
f = File.new("nice_http.log", mode)
f.sync = true
@logger = Logger.new f
elsif @log == :file
f = File.new("nice_http_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.log", "w")
f = File.new("nice_http_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}.log", mode)
f.sync = true
@logger = Logger.new f
elsif @log == :screen
Expand Down
4 changes: 2 additions & 2 deletions nice_http.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'nice_http'
s.version = '1.3.1'
s.version = '1.3.2'
s.summary = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources."
s.description = "NiceHttp -- simplest library for accessing and testing HTTP and REST resources. Manage different hosts on the fly. Easily get the value you want from the JSON strings. Use hashes on your requests."
s.authors = ["Mario Ruiz"]
Expand All @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = ["LICENSE","README.md"]
s.homepage = 'https://github.com/MarioRuiz/nice_http'
s.license = 'MIT'
s.add_runtime_dependency 'nice_hash', ['>= 1.8.1']
s.add_runtime_dependency 'nice_hash', '~> 1.9', '>= 1.9.0'
s.add_development_dependency 'rspec', '~> 3.8', '>= 3.8.0'
s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.22'
s.test_files = s.files.grep(%r{^(test|spec|features)/})
Expand Down

0 comments on commit 0579c54

Please sign in to comment.