chrono_logger 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chrono_logger.rb +4 -1
- data/lib/chrono_logger/version.rb +1 -1
- data/test/test_chrono_logger.rb +52 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd8e8db4d085af832c0cb76c093aebcaa8b916a
|
4
|
+
data.tar.gz: d65ffb9adebb0df5ebd7fc10c06e1b029f74b13d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c08cee180eae5b406613b6de088de54cc606fc1d675d5fc1fc001b13cd9f7d27710f694e108ece6f22c489c42071fc582961781eeb76f936368969636a352108
|
7
|
+
data.tar.gz: 6e75c498bb9e989415f826b85ac901810199e3d6126151d1ae84a8f90395e3f9f4bb8ca94e6b6503915441bc47c9b58d6315ed10471fe9b88fb6e982cbc6d28b
|
data/lib/chrono_logger.rb
CHANGED
@@ -20,7 +20,10 @@ class ChronoLogger < Logger
|
|
20
20
|
|
21
21
|
def determine_period(format)
|
22
22
|
case format
|
23
|
-
when /%
|
23
|
+
when /%[SscXrT]/ then nil # seconds
|
24
|
+
when /%[MR]/ then nil # minutes
|
25
|
+
when /%[HklI]/ then nil # hours
|
26
|
+
when /%[dejDFvx]/ then DAILY
|
24
27
|
else nil
|
25
28
|
end
|
26
29
|
end
|
data/test/test_chrono_logger.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'helper'
|
2
2
|
require 'tempfile'
|
3
|
+
require 'tmpdir'
|
3
4
|
require 'parallel'
|
4
5
|
require 'delorean'
|
5
6
|
|
@@ -28,6 +29,57 @@ class TestChronoLogger < Test::Unit::TestCase
|
|
28
29
|
confirm_daily_rotation(in_processes: 2)
|
29
30
|
end
|
30
31
|
|
32
|
+
def test_rotation_per_second
|
33
|
+
Dir.mktmpdir do |tmpdir|
|
34
|
+
begin
|
35
|
+
logger = ChronoLogger.new([tmpdir, '%Y%m%dT%H%M%S'].join)
|
36
|
+
Delorean.time_travel_to '2014-01-01 23:59:50'
|
37
|
+
logger.debug 'rotation'
|
38
|
+
Delorean.time_travel_to '2014-01-01 23:59:51'
|
39
|
+
logger.debug 'per second'
|
40
|
+
|
41
|
+
assert { File.exist?([tmpdir, '20140101T235950'].join) }
|
42
|
+
assert { File.exist?([tmpdir, '20140101T235951'].join) }
|
43
|
+
ensure
|
44
|
+
Delorean.back_to_the_present
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class PeriodTest
|
50
|
+
include ChronoLogger::Period
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_period
|
54
|
+
period = PeriodTest.new
|
55
|
+
# seconds not supported
|
56
|
+
assert { period.determine_period('%d%S').nil? }
|
57
|
+
assert { period.determine_period('%e%s').nil? }
|
58
|
+
assert { period.determine_period('%j%c').nil? }
|
59
|
+
assert { period.determine_period('%j%r').nil? }
|
60
|
+
assert { period.determine_period('%j%X').nil? }
|
61
|
+
assert { period.determine_period('%j%T').nil? }
|
62
|
+
|
63
|
+
# minutes not supported
|
64
|
+
assert { period.determine_period('%d%M').nil? }
|
65
|
+
assert { period.determine_period('%e%R').nil? }
|
66
|
+
|
67
|
+
# hours not supported
|
68
|
+
assert { period.determine_period('%d%H').nil? }
|
69
|
+
assert { period.determine_period('%e%k').nil? }
|
70
|
+
assert { period.determine_period('%e%l').nil? }
|
71
|
+
assert { period.determine_period('%e%I').nil? }
|
72
|
+
|
73
|
+
# days
|
74
|
+
assert { period.determine_period('%Y%m%d') == ChronoLogger::Period::DAILY }
|
75
|
+
assert { period.determine_period('%Y%m%e') == ChronoLogger::Period::DAILY }
|
76
|
+
assert { period.determine_period('%Y%j') == ChronoLogger::Period::DAILY }
|
77
|
+
assert { period.determine_period('%D') == ChronoLogger::Period::DAILY }
|
78
|
+
assert { period.determine_period('%F') == ChronoLogger::Period::DAILY }
|
79
|
+
assert { period.determine_period('%v') == ChronoLogger::Period::DAILY }
|
80
|
+
assert { period.determine_period('%x') == ChronoLogger::Period::DAILY }
|
81
|
+
end
|
82
|
+
|
31
83
|
private
|
32
84
|
|
33
85
|
def confirm_daily_rotation(option)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrono_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takayuki Matsubara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|