birling 0.1.3 → 0.2.0
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 +4 -4
- data/.travis.yml +10 -0
- data/Gemfile +4 -3
- data/LICENSE.txt +1 -1
- data/README.md +6 -6
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/birling.gemspec +23 -19
- data/lib/birling.rb +9 -0
- data/lib/birling/formatter.rb +8 -0
- data/lib/birling/logger.rb +58 -20
- data/lib/birling/support.rb +4 -0
- data/test/helper.rb +3 -3
- data/test/test_birling.rb +0 -13
- data/test/test_birling_logger.rb +42 -12
- data/test/test_birling_support.rb +6 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cc4db8e400e00db03c995a74cd74c00fa417399
|
4
|
+
data.tar.gz: a5fbb6997f34142f5c8663b47732fde5ce5ca2fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 644c8a35cd87f0d707a319430e8b1d5662366e5166ac38e0b6acc2ebda83a069926926002abf56aae8ea3d501ab1437475f25669564ccd66eafcedb169556858
|
7
|
+
data.tar.gz: 2d12cd6c9fd88753e4a219475cda6b772c2267a437b63769aabd578c8585cc8cf13fcd79305c1e054c8d804cc4c95bd0654d25276ef0aa87a6d12b82e5ef3435
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -34,8 +34,8 @@ of ten hourly logs:
|
|
34
34
|
```ruby
|
35
35
|
logger = Birling.open(
|
36
36
|
'test.log',
|
37
|
-
:
|
38
|
-
:
|
37
|
+
period: :hourly,
|
38
|
+
retain_count: 10
|
39
39
|
)
|
40
40
|
```
|
41
41
|
|
@@ -46,8 +46,8 @@ that period will be removed:
|
|
46
46
|
```ruby
|
47
47
|
logger = Birling.open(
|
48
48
|
'test.log',
|
49
|
-
:
|
50
|
-
:
|
49
|
+
period: :hourly,
|
50
|
+
retain_period: 10 * 3600
|
51
51
|
)
|
52
52
|
```
|
53
53
|
|
@@ -60,7 +60,7 @@ Example:
|
|
60
60
|
```ruby
|
61
61
|
logger = Birling.open(
|
62
62
|
'test.log',
|
63
|
-
:
|
63
|
+
formatter: -> (severity, time, program, message) { "#{time}> #{message}\n" }
|
64
64
|
)
|
65
65
|
```
|
66
66
|
|
@@ -76,4 +76,4 @@ using `STDOUT` the logger will not rotate.
|
|
76
76
|
|
77
77
|
## Copyright
|
78
78
|
|
79
|
-
Copyright (c) 2011-
|
79
|
+
Copyright (c) 2011-2017 Scott Tadman, PostageApp, The Working Group Inc.
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ require 'jeweler'
|
|
14
14
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
gem.name = "birling"
|
17
|
-
gem.homepage = "http://github.com/
|
17
|
+
gem.homepage = "http://github.com/postageapp/birling"
|
18
18
|
gem.license = "MIT"
|
19
19
|
gem.summary = %Q{Logger with simple log rotation system}
|
20
20
|
gem.description = %Q{Mostly drop-in replacement for Logger with a more robust log rotation facility}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/birling.gemspec
CHANGED
@@ -2,24 +2,25 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: birling 0.
|
5
|
+
# stub: birling 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
|
-
s.name = "birling"
|
9
|
-
s.version = "0.
|
8
|
+
s.name = "birling".freeze
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.require_paths = ["lib"]
|
13
|
-
s.authors = ["Scott Tadman"]
|
14
|
-
s.date = "
|
15
|
-
s.description = "Mostly drop-in replacement for Logger with a more robust log rotation facility"
|
16
|
-
s.email = "github@tadman.ca"
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Scott Tadman".freeze]
|
14
|
+
s.date = "2017-12-13"
|
15
|
+
s.description = "Mostly drop-in replacement for Logger with a more robust log rotation facility".freeze
|
16
|
+
s.email = "github@tadman.ca".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
19
19
|
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
+
".travis.yml",
|
23
24
|
"Gemfile",
|
24
25
|
"LICENSE.txt",
|
25
26
|
"README.md",
|
@@ -35,24 +36,27 @@ Gem::Specification.new do |s|
|
|
35
36
|
"test/test_birling_logger.rb",
|
36
37
|
"test/test_birling_support.rb"
|
37
38
|
]
|
38
|
-
s.homepage = "http://github.com/
|
39
|
-
s.licenses = ["MIT"]
|
40
|
-
s.rubygems_version = "2.
|
41
|
-
s.summary = "Logger with simple log rotation system"
|
39
|
+
s.homepage = "http://github.com/postageapp/birling".freeze
|
40
|
+
s.licenses = ["MIT".freeze]
|
41
|
+
s.rubygems_version = "2.6.13".freeze
|
42
|
+
s.summary = "Logger with simple log rotation system".freeze
|
42
43
|
|
43
44
|
if s.respond_to? :specification_version then
|
44
45
|
s.specification_version = 4
|
45
46
|
|
46
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_development_dependency(%q<bundler
|
48
|
-
s.add_development_dependency(%q<
|
48
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
49
51
|
else
|
50
|
-
s.add_dependency(%q<bundler
|
51
|
-
s.add_dependency(%q<
|
52
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
53
|
+
s.add_dependency(%q<test-unit>.freeze, [">= 0"])
|
54
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
52
55
|
end
|
53
56
|
else
|
54
|
-
s.add_dependency(%q<bundler
|
55
|
-
s.add_dependency(%q<
|
57
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
58
|
+
s.add_dependency(%q<test-unit>.freeze, [">= 0"])
|
59
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
data/lib/birling.rb
CHANGED
@@ -7,6 +7,15 @@ class Birling
|
|
7
7
|
|
8
8
|
# == Module Methods =======================================================
|
9
9
|
|
10
|
+
# Opens a new log file at the given path with options:
|
11
|
+
# * encoding: The encoding of the file (default: 'UTF8')
|
12
|
+
# * period: The rotation period to use (optional)
|
13
|
+
# * retain_count: How many log files to retain when rotating (optional)
|
14
|
+
# * retain_period: How long rotated log files are retained for (optional)
|
15
|
+
# * formatter: Custom log formatter (optional)
|
16
|
+
# * program: Name of program being logged (optional)
|
17
|
+
# * time_source: Source of time to use (optional)
|
18
|
+
# * path_format: The strftime-compatible format for the path (optional)
|
10
19
|
def self.open(path, options = nil)
|
11
20
|
Birling::Logger.new(path, options)
|
12
21
|
end
|
data/lib/birling/formatter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
1
3
|
module Birling::Formatter
|
2
4
|
# == Constants ============================================================
|
3
5
|
|
@@ -5,6 +7,12 @@ module Birling::Formatter
|
|
5
7
|
|
6
8
|
# == Module Methods =======================================================
|
7
9
|
|
10
|
+
# Default time formatter method.
|
11
|
+
def self.time_format(time)
|
12
|
+
(time || Time.now).strftime(TIME_FORMAT_DEFAULT)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Implementation for a plug-in Logger formatter.
|
8
16
|
def self.call(severity, time, program, message)
|
9
17
|
if (program)
|
10
18
|
"[#{time.strftime(TIME_FORMAT_DEFAULT)}] <#{program}> #{message}\n"
|
data/lib/birling/logger.rb
CHANGED
@@ -3,15 +3,15 @@ class Birling::Logger
|
|
3
3
|
|
4
4
|
# These level constants are the same as the syslog system utility
|
5
5
|
SEVERITY = {
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
6
|
+
emergency: EMERGENCY = 0,
|
7
|
+
alert: ALERT = 1,
|
8
|
+
critical: CRITICAL = 2,
|
9
|
+
error: ERROR = 3,
|
10
|
+
warning: WARNING = 4,
|
11
|
+
notice: NOTICE = 5,
|
12
|
+
info: INFO = 6,
|
13
|
+
debug: DEBUG = 7,
|
14
|
+
unknown: UNKNOWN = 999
|
15
15
|
}.freeze
|
16
16
|
|
17
17
|
DEFAULT_SEVERITY = UNKNOWN
|
@@ -19,9 +19,9 @@ class Birling::Logger
|
|
19
19
|
SEVERITY_LABEL = SEVERITY.invert.freeze
|
20
20
|
|
21
21
|
PATH_TIME_DEFAULT = {
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
22
|
+
hourly: '%Y%m%d%H'.freeze,
|
23
|
+
daily: '%Y%m%d'.freeze,
|
24
|
+
default: '%s'.freeze
|
25
25
|
}.freeze
|
26
26
|
|
27
27
|
# == Properties ===========================================================
|
@@ -47,7 +47,7 @@ class Birling::Logger
|
|
47
47
|
SEVERITY[value] or DEFAULT_SEVERITY
|
48
48
|
when String
|
49
49
|
SEVERITY[value.to_sym] or DEFAULT_SEVERITY
|
50
|
-
when
|
50
|
+
when Integer
|
51
51
|
SEVERITY_LABEL[value] and value or DEFAULT_SEVERITY
|
52
52
|
else
|
53
53
|
DEFAULT_SEVERITY
|
@@ -56,6 +56,7 @@ class Birling::Logger
|
|
56
56
|
|
57
57
|
# == Instance Methods =====================================================
|
58
58
|
|
59
|
+
# Use Birling.open(...) to create new instances.
|
59
60
|
def initialize(log, options = nil)
|
60
61
|
@encoding = (options and options[:encoding])
|
61
62
|
@period = (options and options[:period])
|
@@ -69,6 +70,10 @@ class Birling::Logger
|
|
69
70
|
|
70
71
|
@file_open_options = { }
|
71
72
|
|
73
|
+
@rotation_time = nil
|
74
|
+
@path = nil
|
75
|
+
@log = nil
|
76
|
+
|
72
77
|
if (@encoding)
|
73
78
|
@file_open_options[:encoding] = @encoding
|
74
79
|
end
|
@@ -98,18 +103,21 @@ class Birling::Logger
|
|
98
103
|
yield(self) if (block_given?)
|
99
104
|
end
|
100
105
|
|
106
|
+
# Sets the severity filter for logging. Any messages with a lower severity
|
107
|
+
# will be ignored. Any invalid severity options will reset the severity
|
108
|
+
# filter to defaults.
|
101
109
|
def severity=(value)
|
102
110
|
@severity = self.class.severity(value)
|
103
111
|
end
|
104
112
|
|
113
|
+
# Returns true if the log can be rotated, false otherwise.
|
105
114
|
def can_rotate?
|
106
115
|
!!@path
|
107
116
|
end
|
108
117
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
118
|
+
# Sets the retention interval for log files. Value should respond to to_i
|
119
|
+
# and yield an integer value that's a positive number of seconds between
|
120
|
+
# rotation operations.
|
113
121
|
def retain=(value)
|
114
122
|
@retain = value ? value.to_i : nil
|
115
123
|
|
@@ -120,6 +128,24 @@ class Birling::Logger
|
|
120
128
|
@retain_period
|
121
129
|
end
|
122
130
|
|
131
|
+
# An IO compatible method for writing a message to the file. Only non-empty
|
132
|
+
# messages are actually logged.
|
133
|
+
def write(message)
|
134
|
+
return unless (message.match(/\S/))
|
135
|
+
|
136
|
+
self.log(:debug, message.chomp)
|
137
|
+
end
|
138
|
+
|
139
|
+
def sync=(sync)
|
140
|
+
# Auto-sync is always turned on, so this operation is ignored.
|
141
|
+
end
|
142
|
+
|
143
|
+
def flush
|
144
|
+
# Auto-sync is always turned on, so this operation is ignored.
|
145
|
+
end
|
146
|
+
|
147
|
+
# Log the message for the (optional) program at the given log level. No
|
148
|
+
# data will be written if the current log level is not sufficiently high.
|
123
149
|
def log(level, message = nil, program = nil)
|
124
150
|
return unless (@log)
|
125
151
|
|
@@ -132,6 +158,7 @@ class Birling::Logger
|
|
132
158
|
end
|
133
159
|
alias_method :add, :log
|
134
160
|
|
161
|
+
# Writes to the log file regardless of log level.
|
135
162
|
def <<(message)
|
136
163
|
return unless (@log)
|
137
164
|
|
@@ -140,6 +167,11 @@ class Birling::Logger
|
|
140
167
|
@log.write(message)
|
141
168
|
end
|
142
169
|
|
170
|
+
# Each of the severity levels has an associated method name. For example:
|
171
|
+
# * debug? - Returns true if the logging level is at least debug, false
|
172
|
+
# otherwise.
|
173
|
+
# * debug(message, program = nil) - Used to log a message with an optional
|
174
|
+
# program name.
|
143
175
|
SEVERITY.each do |name, level|
|
144
176
|
define_method(:"#{name}?") do
|
145
177
|
@severity >= level
|
@@ -160,6 +192,7 @@ class Birling::Logger
|
|
160
192
|
end
|
161
193
|
end
|
162
194
|
|
195
|
+
# Closes the log.
|
163
196
|
def close
|
164
197
|
return unless (@log)
|
165
198
|
|
@@ -167,30 +200,35 @@ class Birling::Logger
|
|
167
200
|
@log = nil
|
168
201
|
end
|
169
202
|
|
203
|
+
# Returns true if the log is opened, false otherwise.
|
170
204
|
def opened?
|
171
205
|
!!@log
|
172
206
|
end
|
173
207
|
|
208
|
+
# Returns true if the log is closed, false otherwise.
|
174
209
|
def closed?
|
175
210
|
!@log
|
176
211
|
end
|
177
212
|
|
213
|
+
# Returns the creation time of the log if opened, nil otherwise.
|
178
214
|
def create_time
|
179
215
|
@log and @log.ctime
|
180
216
|
end
|
181
217
|
|
218
|
+
# Returns size of the log if opened, nil otherwise.
|
182
219
|
def size
|
183
220
|
@log and @log.size
|
184
221
|
end
|
185
222
|
|
223
|
+
# Returns the age of the log file in seconds if opened, nil otherwise.
|
186
224
|
def age(relative_to = nil)
|
187
|
-
(relative_to || @time_source.now) - @log.ctime
|
225
|
+
@log and (relative_to || @time_source.now) - @log.ctime
|
188
226
|
end
|
189
227
|
|
190
228
|
protected
|
191
229
|
def next_rotation_time
|
192
230
|
case (@period)
|
193
|
-
when
|
231
|
+
when Integer, Float
|
194
232
|
@time_source.now + @period
|
195
233
|
when :daily
|
196
234
|
Birling::Support.next_day(@time_source.now)
|
@@ -250,7 +288,7 @@ protected
|
|
250
288
|
@log = File.open(@current_path, 'a', @file_open_options)
|
251
289
|
@log.sync = true
|
252
290
|
|
253
|
-
if (File.
|
291
|
+
if (File.symlink?(@path))
|
254
292
|
File.unlink(@path)
|
255
293
|
end
|
256
294
|
|
data/lib/birling/support.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module Birling::Support
|
2
|
+
# == Module + Mixin Methods ===============================================
|
3
|
+
|
4
|
+
# Computes the beginning of the next day.
|
2
5
|
def next_day(time, time_source = nil)
|
3
6
|
(time_source || Time).local(
|
4
7
|
time.year,
|
@@ -10,6 +13,7 @@ module Birling::Support
|
|
10
13
|
) + 1
|
11
14
|
end
|
12
15
|
|
16
|
+
# Computes the beginning of the next hour.
|
13
17
|
def next_hour(time, time_source = nil)
|
14
18
|
seconds_left = time.to_i % 3600
|
15
19
|
|
data/test/helper.rb
CHANGED
@@ -54,9 +54,9 @@ class Test::Unit::TestCase
|
|
54
54
|
name = "#{name}.log"
|
55
55
|
end
|
56
56
|
|
57
|
-
|
57
|
+
temp_path ||= File.expand_path('../tmp', File.dirname(__FILE__))
|
58
58
|
|
59
|
-
full_path = File.expand_path(name,
|
59
|
+
full_path = File.expand_path(name, temp_path)
|
60
60
|
|
61
61
|
FileUtils::mkdir_p(File.dirname(full_path))
|
62
62
|
|
@@ -64,7 +64,7 @@ class Test::Unit::TestCase
|
|
64
64
|
begin
|
65
65
|
yield(full_path)
|
66
66
|
ensure
|
67
|
-
remove_spec = File.expand_path('*',
|
67
|
+
remove_spec = File.expand_path('*', temp_path)
|
68
68
|
|
69
69
|
FileUtils.rm_f(Dir.glob(remove_spec))
|
70
70
|
end
|
data/test/test_birling.rb
CHANGED
@@ -35,17 +35,4 @@ class TestBirling < Test::Unit::TestCase
|
|
35
35
|
|
36
36
|
assert !File.exist?(_path)
|
37
37
|
end
|
38
|
-
|
39
|
-
def test_time_warped
|
40
|
-
_now = Time.now
|
41
|
-
|
42
|
-
Time::Warped.now = _now
|
43
|
-
|
44
|
-
assert_not_equal Time.now, Time.now
|
45
|
-
assert_equal _now, Time::Warped.now
|
46
|
-
|
47
|
-
Time::Warped.now = nil
|
48
|
-
|
49
|
-
assert_not_equal _now, Time::Warped.now
|
50
|
-
end
|
51
38
|
end
|
data/test/test_birling_logger.rb
CHANGED
@@ -27,6 +27,35 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
27
27
|
|
28
28
|
assert_equal 0, log.size
|
29
29
|
end
|
30
|
+
|
31
|
+
def test_io_compatible
|
32
|
+
stdout = $stdout
|
33
|
+
|
34
|
+
buffer = StringIO.new
|
35
|
+
|
36
|
+
log = Birling::Logger.new(buffer, time_source: Time::Warped)
|
37
|
+
|
38
|
+
assert log.opened?
|
39
|
+
|
40
|
+
assert_equal 0, log.size
|
41
|
+
|
42
|
+
$stdout = log
|
43
|
+
|
44
|
+
start = Time.parse('2017-10-10 12:00:00')
|
45
|
+
|
46
|
+
Time::Warped.now = start
|
47
|
+
|
48
|
+
puts "Test"
|
49
|
+
|
50
|
+
log.close
|
51
|
+
|
52
|
+
expected = "[2017-10-10 12:00:00] Test\n"
|
53
|
+
|
54
|
+
assert_equal expected, buffer.string.to_s
|
55
|
+
|
56
|
+
ensure
|
57
|
+
$stdout = stdout
|
58
|
+
end
|
30
59
|
|
31
60
|
def test_formatter
|
32
61
|
formatter_called = false
|
@@ -36,7 +65,7 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
36
65
|
end
|
37
66
|
|
38
67
|
output = StringIO.new
|
39
|
-
log = Birling::Logger.new(output, :
|
68
|
+
log = Birling::Logger.new(output, formatter: formatter)
|
40
69
|
|
41
70
|
log.debug("Test")
|
42
71
|
|
@@ -72,8 +101,7 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
72
101
|
|
73
102
|
log << "TEST"
|
74
103
|
|
75
|
-
output.
|
76
|
-
assert_equal "TEST", output.read
|
104
|
+
assert_equal "TEST", output.string
|
77
105
|
end
|
78
106
|
|
79
107
|
def test_level_filter
|
@@ -81,8 +109,8 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
81
109
|
|
82
110
|
log = Birling::Logger.new(
|
83
111
|
output,
|
84
|
-
:
|
85
|
-
:
|
112
|
+
formatter: lambda { |s, t, p, m| "#{m}\n" },
|
113
|
+
severity: :info
|
86
114
|
)
|
87
115
|
|
88
116
|
log.debug("DEBUG")
|
@@ -120,7 +148,7 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
120
148
|
frozen_time = Time.now
|
121
149
|
Time::Warped.now = frozen_time
|
122
150
|
|
123
|
-
logger = Birling::Logger.new(path, :
|
151
|
+
logger = Birling::Logger.new(path, time_source: Time::Warped)
|
124
152
|
|
125
153
|
assert_equal frozen_time, logger.time_source.now
|
126
154
|
end
|
@@ -130,7 +158,7 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
130
158
|
temp_path(:cycle) do |path|
|
131
159
|
start = Time.now
|
132
160
|
Time::Warped.now = start
|
133
|
-
logger = Birling::Logger.new(path, :
|
161
|
+
logger = Birling::Logger.new(path, period: 1, time_source: Time::Warped)
|
134
162
|
|
135
163
|
assert_equal 1, logger.period
|
136
164
|
|
@@ -164,14 +192,16 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
164
192
|
|
165
193
|
logger = Birling::Logger.new(
|
166
194
|
path,
|
167
|
-
:
|
168
|
-
:
|
169
|
-
:
|
195
|
+
period: 1,
|
196
|
+
time_source: Time::Warped,
|
197
|
+
retain_count: retain_count
|
170
198
|
)
|
171
199
|
|
172
200
|
(retain_count + 5).times do |n|
|
173
201
|
logger.debug("Test")
|
202
|
+
|
174
203
|
Time::Warped.now += 1
|
204
|
+
|
175
205
|
logger.debug("Test")
|
176
206
|
end
|
177
207
|
|
@@ -201,8 +231,8 @@ class TestBirlingLogger < Test::Unit::TestCase
|
|
201
231
|
|
202
232
|
logger = Birling::Logger.new(
|
203
233
|
path,
|
204
|
-
:
|
205
|
-
:
|
234
|
+
period: 1,
|
235
|
+
retain_period: retain_period
|
206
236
|
)
|
207
237
|
|
208
238
|
assert_equal true, File.exist?(path)
|
@@ -4,6 +4,8 @@ class TestBirlingSupport < Test::Unit::TestCase
|
|
4
4
|
def test_next_day_on_dst_flip
|
5
5
|
in_time_zone('EST5EDT') do
|
6
6
|
time = Time.new(2012, 11, 4)
|
7
|
+
|
8
|
+
assert_equal 'EDT', time.zone
|
7
9
|
|
8
10
|
assert_equal time.day, (time + 86400).day
|
9
11
|
|
@@ -21,6 +23,8 @@ class TestBirlingSupport < Test::Unit::TestCase
|
|
21
23
|
def test_hour_day_on_dst_flip
|
22
24
|
in_time_zone('EST5EDT') do
|
23
25
|
time = Time.new(2012, 11, 4, 0, 59, 59) + 1
|
26
|
+
|
27
|
+
assert_equal 'EDT', time.zone
|
24
28
|
|
25
29
|
assert_equal time.hour, (time + 3600).hour
|
26
30
|
|
@@ -40,6 +44,8 @@ class TestBirlingSupport < Test::Unit::TestCase
|
|
40
44
|
def test_next_day_at_year_end
|
41
45
|
in_time_zone('EST5EDT') do
|
42
46
|
time = Time.new(2012, 12, 31)
|
47
|
+
|
48
|
+
assert_equal 'EST', time.zone
|
43
49
|
|
44
50
|
next_day = Birling::Support.next_day(time)
|
45
51
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Tadman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: jeweler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,6 +62,7 @@ extra_rdoc_files:
|
|
48
62
|
- README.md
|
49
63
|
files:
|
50
64
|
- ".document"
|
65
|
+
- ".travis.yml"
|
51
66
|
- Gemfile
|
52
67
|
- LICENSE.txt
|
53
68
|
- README.md
|
@@ -62,7 +77,7 @@ files:
|
|
62
77
|
- test/test_birling.rb
|
63
78
|
- test/test_birling_logger.rb
|
64
79
|
- test/test_birling_support.rb
|
65
|
-
homepage: http://github.com/
|
80
|
+
homepage: http://github.com/postageapp/birling
|
66
81
|
licenses:
|
67
82
|
- MIT
|
68
83
|
metadata: {}
|
@@ -82,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
97
|
version: '0'
|
83
98
|
requirements: []
|
84
99
|
rubyforge_project:
|
85
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.6.13
|
86
101
|
signing_key:
|
87
102
|
specification_version: 4
|
88
103
|
summary: Logger with simple log rotation system
|