simple_rotate 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 481428ce2f0316a88fabc15531a03bb722641a86
4
- data.tar.gz: 482f5c5d2154f63ef017817941e049ed7078dff3
3
+ metadata.gz: be22a3c38d7b281549b2f6f2b782793ba8a6a3ab
4
+ data.tar.gz: d19711617196e08109a09c536010ce4296cd886f
5
5
  SHA512:
6
- metadata.gz: 50bdabad14095319c3caaeb70df3c5ed79b6a76d637ba7a44863fd644e018624c4afb43aa5f633635a86b5250a54b53ce7cb80d29c8663d4394dd50270f7207e
7
- data.tar.gz: 80d19f35402ae0aabc0e099986b2dda5f68efe8b7f3b5f0228628a4c16229ecf24238e743f8068c4531324836270503b6c6e5beed3798a15a3630579cc66963e
6
+ metadata.gz: fcb0a5ad487e2f07c82cf6225155958922d3afde9f2cb9fec950c427482843477a1d149c72fe096227d25bda0b56d8d60dae2c7ce91903629d5d759abef1fb38
7
+ data.tar.gz: c962cdad590764c25af7f8bbee41beb655b8cae1069890474133e6be1c32a44d9837e1b61466abced8b7a6562f091aa69eb5d7d2680e089af520c3503cda18f3
@@ -1,6 +1,6 @@
1
1
  class SimpleRotate
2
2
  LIBS_NAME = "simple_rotate"
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  SUMMARY = "Simple and safety logger."
5
5
  HOMEPAGE = "http://khotta.github.io/"
6
6
  DESCRIPTION = "#{SUMMARY} #{HOMEPAGE}"
@@ -16,16 +16,15 @@ class SimpleRotate
16
16
  end
17
17
 
18
18
  def initialize(sr)
19
- @sr = sr
20
- @enable = sr.instance_variable_get(:@is_psync)
21
- @file_name = sr.instance_variable_get(:@file_name)
19
+ @sr = sr
20
+ @enable = sr.instance_variable_defined?(:@is_psync) ? sr.instance_variable_get(:@is_psync) : nil
21
+ file_name = sr.instance_variable_defined?(:@file_name) ? sr.instance_variable_get(:@file_name) : nil
22
22
 
23
23
  # #init not called
24
- return self if @file_name == nil
24
+ return self if file_name == nil
25
25
 
26
- @logf = sr.instance_variable_get(:@logf)
27
26
  @try_limit = 3
28
- @@tempf_name = File.dirname(@file_name) + File::SEPARATOR + ".SimpleRotate_tempfile_#{File.basename($0)}"
27
+ @@tempf_name = File.dirname(file_name) + File::SEPARATOR + ".SimpleRotate_tempfile_#{File.basename($0)}"
29
28
 
30
29
  create_tempfile if @enable && !@@scheduled_del_lockfile
31
30
  end
@@ -59,7 +58,7 @@ class SimpleRotate
59
58
  def set_delete_tempfile
60
59
  return true if @@scheduled_del_lockfile
61
60
 
62
- if File.exists?(@@tempf_name)
61
+ if File.exist?(@@tempf_name)
63
62
  # is it empty?
64
63
  if File.size(@@tempf_name) == 0
65
64
  delete_at_end
@@ -45,11 +45,11 @@ class SimpleRotate
45
45
  @logf.puts("created@#{gtime}@Please don't delete this line")
46
46
  @logf.close
47
47
 
48
- rescue
49
- SimpleRotate::Error.open(@file_name)
50
- end
48
+ rescue
49
+ SimpleRotate::Error.open(@file_name)
50
+ end
51
51
 
52
- openadd
52
+ openadd
53
53
  end
54
54
 
55
55
  # if file or directory exist, call error
@@ -82,7 +82,7 @@ class SimpleRotate
82
82
  que << [%{@sleep_time}, %{0}]
83
83
 
84
84
  que.each do |q|
85
- if eval(%{#{q[0]} == nil})
85
+ if !eval(%{self.instance_variable_defined? :#{q[0]}})
86
86
  eval(%{#{q[0]} = #{q[1]}})
87
87
  end
88
88
  end
@@ -213,7 +213,12 @@ class SimpleRotate
213
213
  # @return string
214
214
  private
215
215
  def get_trimmed_log(log)
216
- log = log.to_s
216
+ if log == nil
217
+ log = log.inspect
218
+ else
219
+ log = log.to_s
220
+ end
221
+
217
222
  date = Time.now.strftime(@date_format)
218
223
  level = eval("LOG_LEVEL_#{@log_level}")
219
224
  return @logging_format.gsub("$DATE", date)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_rotate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - khotta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-12-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple and safety logger. http://khotta.github.io/
14
14
  email: