evanescent 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evanescent.rb +27 -5
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c0460154818ebb24936f927d692124020c8556
|
4
|
+
data.tar.gz: 66225a80f1f380b06bb869da37355e09e7d40599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f901c5efbfac38bb3309865cde45c2f67dc1d1c4e4682fca6900d905a36b2d396ceca8a36b1118f3f7526e106eb6499e9b69b1a1b3e9ba9bdf1b50e77bf97d06
|
7
|
+
data.tar.gz: b9b058a9cedd08d98b70e2a4a9e3971d765a19f23e98812ac620cb5a5fc188b72bddbeadae7ee90c091b2b7730c7cd7e35c2cc85820f2ef706b35a435dd79c7d
|
data/lib/evanescent.rb
CHANGED
@@ -74,11 +74,13 @@ class Evanescent
|
|
74
74
|
PARAMS = {
|
75
75
|
hourly: {
|
76
76
|
strftime: '%Y%m%d%H',
|
77
|
-
glob: '[0-9]' * (4 + 2 * 3)
|
77
|
+
glob: '[0-9]' * (4 + 2 * 3),
|
78
|
+
interval: 3600
|
78
79
|
},
|
79
80
|
daily: {
|
80
81
|
strftime: '%Y%m%d',
|
81
|
-
glob: '[0-9]' * (4 + 2 * 2)
|
82
|
+
glob: '[0-9]' * (4 + 2 * 2),
|
83
|
+
interval: 3600 * 24
|
82
84
|
}
|
83
85
|
}
|
84
86
|
|
@@ -87,17 +89,37 @@ class Evanescent
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def rotate
|
92
|
+
if @io
|
93
|
+
rotate_with_open_io
|
94
|
+
else
|
95
|
+
rotate_with_closed_io
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def rotate_with_open_io
|
90
100
|
curr_suffix = make_prefix(Time.now)
|
91
101
|
return if curr_suffix == @last_prefix
|
92
102
|
@io.close
|
93
103
|
@io = nil
|
94
|
-
|
104
|
+
do_rotation("#{path}.#{curr_suffix}")
|
105
|
+
@last_prefix = curr_suffix
|
106
|
+
end
|
107
|
+
|
108
|
+
def rotate_with_closed_io
|
109
|
+
return unless File.exist?(path)
|
110
|
+
curr_suffix = make_prefix(Time.now+PARAMS[rotation][:interval])
|
111
|
+
rotation_suffix = make_prefix(File.mtime(path) + PARAMS[rotation][:interval])
|
112
|
+
return if curr_suffix == rotation_suffix
|
113
|
+
do_rotation("#{path}.#{rotation_suffix}")
|
114
|
+
@last_prefix = curr_suffix
|
115
|
+
end
|
116
|
+
|
117
|
+
def do_rotation new_path
|
95
118
|
begin
|
96
|
-
FileUtils.mv(path,
|
119
|
+
FileUtils.mv(path, new_path)
|
97
120
|
rescue
|
98
121
|
warn("Error renaming '#{path}' to '#{rotated}': #{$!}")
|
99
122
|
end
|
100
|
-
@last_prefix = curr_suffix
|
101
123
|
end
|
102
124
|
|
103
125
|
def compress
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evanescent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Pugliese Ornellas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic_duration
|
@@ -112,12 +112,12 @@ dependencies:
|
|
112
112
|
- - "~>"
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0.8'
|
115
|
-
description:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
description: 'This gem provides an IO like object, that can be used with any logging
|
116
|
+
class (such as Ruby''s native Logger). This object will save its input to a file,
|
117
|
+
and allows: rotation by time / date, compression of old files and removal of old
|
118
|
+
compressed files. Its purpuse is to supplement logging classes, allowing everything
|
119
|
+
related to logging management, to be done within Ruby, without relying on external
|
120
|
+
tools (such as logrotate).'
|
121
121
|
email: fabio.ornellas@gmail.com
|
122
122
|
executables: []
|
123
123
|
extensions: []
|