woolen_common 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57fcb758f43720755bd3ec8b8f811e6082b28004
4
- data.tar.gz: 0dee7bc01a35579d4ca912699199cd13f3260ce5
3
+ metadata.gz: 041e69562b002c4b6797f10b5739b3cfba53ec17
4
+ data.tar.gz: cfa1b51cf3365b2823e0b0119a11e812d8e2b47d
5
5
  SHA512:
6
- metadata.gz: ca411694e311a103c70cd92f7037ab29b8e4b267b187f52accfad6e764179e9eb6652d91bdc3ed85589e0dcbd9463438d28d267ddb00c618768f0291e49e9f0a
7
- data.tar.gz: 46f534130b0ab677702f272744375c55285382715da3e925a95d2c795ecaa13a8475cfeb4199cea0168c2f7dd932778209c3569ca677b5ec3f73d584daf9178c
6
+ metadata.gz: 0ba57396a19c91fb3df38477723ea5dd66eee1444a67ad14df5bd937891494a54dbf41f8ba7059dce87679059a1db39c2a3c9d69ec9126c8cfea37f53063ef74
7
+ data.tar.gz: 51f3b745df5cb22d74f9501cbf6cdf1e4458c58e1e1eadbe812bcdb9a19427a082f1f01d5cadb066af8a6a24f526993cd3a30b94fe970f02c375e2967ca15ab8
@@ -146,13 +146,13 @@ module WoolenCommon
146
146
  def rename_and_create_new(newfilename)
147
147
  # fix Error::EACCESS exception throw when file is opened before rename by lyf
148
148
  begin
149
- @file.flush
150
- @file.close
149
+ @file.flush rescue nil
150
+ @file.close rescue nil
151
151
  FileUtils.cp(@file.path, newfilename)
152
- clean_log @file.path
152
+ clean_log @file.path rescue nil
153
153
  @file.reopen(@file.path, "w")
154
154
  rescue Exception => e
155
- puts "error when try to rename_and_create_new #{newfilename}"
155
+ puts "error when try to rename_and_create_new #{newfilename},#{e.message}"
156
156
  end
157
157
  #unless (FileUtils.cp(@file.path, newfilename) and FileUtils.rm_f(@file.path) and @file.reopen(@file.path, "w"))
158
158
  # #puts "==> error rename #{@filename} => #{newfilename}"
@@ -175,10 +175,10 @@ module WoolenCommon
175
175
  end
176
176
  end
177
177
 
178
- def check_split_file
178
+ def check_split_file(force=false)
179
179
  begin
180
- if @roll_type == "daily"
181
- if @last_log_time && @last_log_time.day != Time.now.day
180
+ if @roll_type == 'daily'
181
+ if force or (@last_log_time && @last_log_time.day != Time.now.day)
182
182
  p = @file.path
183
183
  new_name = nil
184
184
  if p.rindex(".") > p.rindex("/")
@@ -188,8 +188,8 @@ module WoolenCommon
188
188
  end
189
189
  rename_and_create_new(new_name)
190
190
  end
191
- elsif @roll_type == "file_size"
192
- if File.size(@file) >= @roll_param
191
+ elsif @roll_type == 'file_size'
192
+ if force or ( File.size(@file) >= @roll_param )
193
193
  p = @file.path
194
194
  new_name = nil
195
195
  if p.rindex(".") > p.rindex("/")
@@ -244,9 +244,13 @@ module WoolenCommon
244
244
  file_need_to_pus_cache << value
245
245
  #@file.dup if @file
246
246
  end
247
- if @file
248
- @file.print file_need_to_pus_cache
249
- @file.flush
247
+ begin
248
+ if @file
249
+ @file.print file_need_to_pus_cache
250
+ @file.flush
251
+ end
252
+ rescue Exception => es
253
+ check_split_file true
250
254
  end
251
255
  end
252
256
  @last_log_time = Time.now
@@ -1,3 +1,3 @@
1
1
  module WoolenCommon
2
- VERSION = '0.0.11'
2
+ VERSION = '0.0.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woolen_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - just_woolen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler