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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98a799c028139790c8c8860d2af59e9058fede33
4
- data.tar.gz: 62463f74007c6410b37a839642456f5e8a650898
3
+ metadata.gz: d09f858d6e4b21b750bc86e2c64f0fb0722f8852
4
+ data.tar.gz: 7b3276e0238d6ea731542ea0fe1f34bb16ec18e6
5
5
  SHA512:
6
- metadata.gz: 80c544bf458a8ddb93049af720e7fddaad2b58b3ad66e770e7cbff1778f7391218b0701f2e98c5853cb417d51379e12757cbf5164429a9478a95d7fc4c84496c
7
- data.tar.gz: 9b7a693186426b2f796eb5c28bcd985571ef33f390c88a8895feceb13c5a6f8cd6cfb925243be614b1695775d7de76a47b506c05f7c50f9bde078909b75b2508
6
+ metadata.gz: 3ec5fea485d8fdeca29adea6c3dc394da6ea15de408d5bef464fb860887c0e9a597ccf689074a00d6eb2bf5cce6958fdd8fae919b965010cc6ad797d4dbb0ee9
7
+ data.tar.gz: 0a70e465679698669febefaae3d1892ce0dfd4c57739ca5c489ebf54238d1c04c2ba6cac7ab1906dc7d5784b48387d1d1f07157138ac675eafd2c069686721bb
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rumbrl (0.1.1)
4
+ rumbrl (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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.
@@ -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
- fail 'requires a message and data' unless args.size == 2
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(message, level: :info, data: {})
47
- @logger.method(level).call { format_message message, data }
44
+ def write(args, level: :info)
45
+ @logger.method(level).call { format_message args }
48
46
  end
49
47
 
50
- def format_message(message, data)
51
- sprintf @data_format, message, data
48
+ def format_message(values)
49
+ sprintf(*([@data_format] + values))
52
50
  end
53
51
 
54
52
  def log_formatter(log_format)
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version const for gem
4
4
  module Rumbrl
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.0'
6
6
  end
@@ -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.1.1
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-06 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop