logger-better 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/logger/better.rb +7 -1
- data/lib/logger-better/version.rb +1 -1
- data/test/better_test.rb +15 -13
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0188f0b4f63a728e7f73321d82ac79b7b8ec92bd
|
4
|
+
data.tar.gz: 2d8c8508931a8471d954ebdcc18a1e25157ba7aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6308239bb7237ed4fa8eb38dd89e9e5da1754ebe691ea43804e1ecf82616b4042cdd2f26b2c81eb6004c65164ca65bf4df2ea8cab4af51bfe33430c561a02461
|
7
|
+
data.tar.gz: eaca5033654f00f6bdb513d65dc64a5b7f51298c92a7dc916437dbc86a09650a086ac0acda326ffeebf56a469a060f3b5840f6fd6452d24176ff0b571372b521
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# logger-better
|
2
2
|
|
3
3
|
Simple monkey patch to stdlib's `Logger` to make it easier to use.
|
4
4
|
|
@@ -9,7 +9,7 @@ projects and got tired of it.
|
|
9
9
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
|
-
gem '
|
12
|
+
gem 'logger-better'
|
13
13
|
|
14
14
|
And then execute:
|
15
15
|
|
@@ -17,7 +17,7 @@ And then execute:
|
|
17
17
|
|
18
18
|
Or install it yourself as:
|
19
19
|
|
20
|
-
$ gem install
|
20
|
+
$ gem install logger-better
|
21
21
|
|
22
22
|
## Enhancements
|
23
23
|
|
data/lib/logger/better.rb
CHANGED
@@ -23,7 +23,13 @@ class Logger
|
|
23
23
|
|
24
24
|
class Formatter
|
25
25
|
def call(severity, time, progname, msg)
|
26
|
-
format % [
|
26
|
+
format % [
|
27
|
+
time.utc.iso8601,
|
28
|
+
progname,
|
29
|
+
$$,
|
30
|
+
severity,
|
31
|
+
msg2str(msg).strip
|
32
|
+
]
|
27
33
|
end
|
28
34
|
|
29
35
|
def format
|
data/test/better_test.rb
CHANGED
@@ -3,51 +3,53 @@ require 'logger/better'
|
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
class BetterTest < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
formatter = Logger::Formatter.new
|
6
|
+
attr_reader :formatter
|
8
7
|
|
8
|
+
def setup
|
9
|
+
@formatter = Logger::Formatter.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_uses_utc_iso_8601_times
|
9
13
|
time = Time.now
|
10
14
|
log = formatter.call 'info', time, 'app', 'hi'
|
11
|
-
assert_includes log, time.iso8601
|
15
|
+
assert_includes log, time.utc.iso8601
|
12
16
|
end
|
13
17
|
|
14
18
|
def test_starts_with_the_time
|
15
|
-
formatter = Logger::Formatter.new
|
16
|
-
|
17
19
|
time = Time.now
|
18
20
|
log = formatter.call 'info', time, 'app', 'hi'
|
19
21
|
assert_equal 0, log.index(time.iso8601)
|
20
22
|
end
|
21
23
|
|
22
24
|
def test_progname_comes_after_time
|
23
|
-
formatter = Logger::Formatter.new
|
24
|
-
|
25
25
|
time = Time.now
|
26
26
|
log = formatter.call 'info', time, 'app', 'hi'
|
27
27
|
assert_before log, 'app', time.iso8601
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_pid_comes_after_progname
|
31
|
-
formatter = Logger::Formatter.new
|
32
|
-
|
33
31
|
log = formatter.call 'info', Time.now, 'app', 'hi'
|
34
32
|
assert_before log, $$.to_s, 'app'
|
35
33
|
end
|
36
34
|
|
37
35
|
def test_level_comes_after_progname
|
38
|
-
formatter = Logger::Formatter.new
|
39
|
-
|
40
36
|
log = formatter.call 'info', Time.now, 'app', 'hi'
|
41
37
|
assert_before log, 'info', $$.to_s
|
42
38
|
end
|
43
39
|
|
44
40
|
def test_message_comes_last
|
45
|
-
formatter = Logger::Formatter.new
|
46
|
-
|
47
41
|
log = formatter.call 'info', Time.now, 'app', 'hi'
|
48
42
|
assert_before log, 'hi', 'info'
|
49
43
|
end
|
50
44
|
|
45
|
+
def test_removes_extra_new_lines_from_end_of_message
|
46
|
+
message = "!\n\n"
|
47
|
+
|
48
|
+
log = formatter.call 'info', Time.now, 'app', message
|
49
|
+
# strip here because all lines will have a new line.
|
50
|
+
assert_equal '!', log.strip[-1]
|
51
|
+
end
|
52
|
+
|
51
53
|
def test_can_set_level_with_symbol
|
52
54
|
logger = Logger.new StringIO.new
|
53
55
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logger-better
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ahawkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.2.
|
81
|
+
rubygems_version: 2.2.2
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Simple monkey patch to stdlib's Logger to make it easier to use.
|