rumbrl 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -0
- data/lib/rumbrl/log.rb +5 -7
- data/lib/rumbrl/version.rb +1 -1
- data/spec/rumbrl/log_spec.rb +10 -5
- 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: d09f858d6e4b21b750bc86e2c64f0fb0722f8852
|
4
|
+
data.tar.gz: 7b3276e0238d6ea731542ea0fe1f34bb16ec18e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ec5fea485d8fdeca29adea6c3dc394da6ea15de408d5bef464fb860887c0e9a597ccf689074a00d6eb2bf5cce6958fdd8fae919b965010cc6ad797d4dbb0ee9
|
7
|
+
data.tar.gz: 0a70e465679698669febefaae3d1892ce0dfd4c57739ca5c489ebf54238d1c04c2ba6cac7ab1906dc7d5784b48387d1d1f07157138ac675eafd2c069686721bb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
rumbrl
|
2
2
|
======
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rumbrl.svg)](http://badge.fury.io/rb/rumbrl)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/behance/rumbrl/badges/gpa.svg)](https://codeclimate.com/github/behance/rumbrl)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/behance/rumbrl/badges/gpa.svg)](https://codeclimate.com/github/behance/rumbrl)
|
7
|
+
|
4
8
|
**R**eally d**UMB** **R**uby **L**ogger
|
5
9
|
|
6
10
|
So dumb you'll cry.
|
data/lib/rumbrl/log.rb
CHANGED
@@ -23,15 +23,13 @@ module Rumbrl
|
|
23
23
|
def initialize(path, age, size, data_format, log_format = nil)
|
24
24
|
@logger = ::Logger.new(log_file(path), shift_age: age, shift_size: size)
|
25
25
|
@data_format = data_format
|
26
|
-
|
27
26
|
@logger.formatter = log_formatter(log_format) if log_format
|
28
27
|
end
|
29
28
|
|
30
29
|
def method_missing(name, *args)
|
31
30
|
name = name.to_sym
|
32
31
|
return super(name, *args) unless ALLOWED_METHODS.member? name
|
33
|
-
|
34
|
-
write(args[0], data: args[1], level: name)
|
32
|
+
write(args, level: name)
|
35
33
|
end
|
36
34
|
|
37
35
|
private
|
@@ -43,12 +41,12 @@ module Rumbrl
|
|
43
41
|
file
|
44
42
|
end
|
45
43
|
|
46
|
-
def write(
|
47
|
-
@logger.method(level).call { format_message
|
44
|
+
def write(args, level: :info)
|
45
|
+
@logger.method(level).call { format_message args }
|
48
46
|
end
|
49
47
|
|
50
|
-
def format_message(
|
51
|
-
sprintf
|
48
|
+
def format_message(values)
|
49
|
+
sprintf(*([@data_format] + values))
|
52
50
|
end
|
53
51
|
|
54
52
|
def log_formatter(log_format)
|
data/lib/rumbrl/version.rb
CHANGED
data/spec/rumbrl/log_spec.rb
CHANGED
@@ -38,11 +38,6 @@ describe Rumbrl::Log do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
context 'method is known' do
|
41
|
-
it 'fails when less than 2 args given' do
|
42
|
-
expect { log.debug('boo') }
|
43
|
-
.to raise_error(RuntimeError, /message and data/)
|
44
|
-
end
|
45
|
-
|
46
41
|
it 'logs correctly using default log_format' do
|
47
42
|
expect_any_instance_of(Logger::LogDevice)
|
48
43
|
.to receive(:write).with(default_log_string('message \["data"\]'))
|
@@ -79,6 +74,16 @@ describe Rumbrl::Log do
|
|
79
74
|
|
80
75
|
log.info('message', 'data')
|
81
76
|
end
|
77
|
+
|
78
|
+
it 'truncates extra values based on format string' do
|
79
|
+
log = Rumbrl::Log.new('path/to/log', 'weekly', 123,
|
80
|
+
'%s %s %s', '%severity% %message%')
|
81
|
+
|
82
|
+
expect_any_instance_of(Logger::LogDevice)
|
83
|
+
.to receive(:write).with("INFO 1 2 3\n")
|
84
|
+
|
85
|
+
log.info(1, 2, 3, 4, 5)
|
86
|
+
end
|
82
87
|
end
|
83
88
|
end
|
84
89
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rumbrl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chr0n1x
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|