ougai 1.9.0 → 1.9.1

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
  SHA256:
3
- metadata.gz: 4b9254ac3650ca12026fbd3d3c6b474a8de478fb81ea82f19fecdff6b62c8b17
4
- data.tar.gz: 95c71a88355673d0821596503057ad46761c3b508ab7a0b72b806462f8a3af7f
3
+ metadata.gz: eedebaea46d0f9d0d03d575e527f2499a2d483e839915c8bbe412de268cd26db
4
+ data.tar.gz: 284223f62d6bd3e1a472a076297f66581bbf718fa5bb0e6cd6bef3515a5ef242
5
5
  SHA512:
6
- metadata.gz: 9c7cdf6d3ad6cfbaae66438cc40971a5cbd978ad9585c2ed4538cea3530184f53a3e0f2a87c22cfcfc581ecbb596eb7b7d2468edc26e7c1b05d27832d856bbcf
7
- data.tar.gz: bed8c16d8e851d7b64d52b86084c13f333a0cee873ab4c1bd8670083c700597a587cb6edf39cead61711af747d30b0723d6bf63ac6eadd1c4de0fb7611d8f16c
6
+ metadata.gz: cc3c4a339f6fbea07ddfb4e75c96f101295da12d73112efaea997217382557c69ac7f130bd26693ecf880c73c65dc07e369dcc9e9b2105ff588cec018a7812bc
7
+ data.tar.gz: abd28e5dc00a61cac547ac8492f272c2d58c75363b3694b9d4334078549d482c4075b9b3f1463486c54c647e427dd33788185b4d11f75bb6abdc6bf9e8bc2a40
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ougai (1.9.0)
4
+ ougai (1.9.1)
5
5
  oj (~> 3.10)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -2,7 +2,7 @@ Ougai
2
2
  =====
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/ougai.svg)](https://badge.fury.io/rb/ougai)
5
- [![document](https://img.shields.io/badge/document-1.9.0-green.svg)](http://www.rubydoc.info/gems/ougai/)
5
+ [![document](https://img.shields.io/badge/document-1.9.1-green.svg)](http://www.rubydoc.info/gems/ougai/)
6
6
  [![Build Status](https://travis-ci.org/tilfin/ougai.svg?branch=master)](https://travis-ci.org/tilfin/ougai)
7
7
  [![Code Climate](https://codeclimate.com/github/tilfin/ougai/badges/gpa.svg)](https://codeclimate.com/github/tilfin/ougai)
8
8
  [![Test Coverage](https://codeclimate.com/github/tilfin/ougai/badges/coverage.svg)](https://codeclimate.com/github/tilfin/ougai/coverage)
@@ -39,8 +39,8 @@ module Ougai
39
39
  # @param logger [Logger] The logger receiving broadcast logs.
40
40
  def self.broadcast(logger)
41
41
  Module.new do |mdl|
42
- define_method(:add) do |*args, &block|
43
- logger.add(*args, &block)
42
+ define_method(:_log) do |*args, &block|
43
+ logger._log(*args, &block)
44
44
  super(*args, &block)
45
45
  end
46
46
 
@@ -28,7 +28,7 @@ module Ougai
28
28
  # @return [Boolean] true
29
29
  # @see Logging#debug
30
30
  def trace(message = nil, ex = nil, data = nil, &block)
31
- add(TRACE, message, ex, data, &block)
31
+ _log(TRACE, message, ex, data, &block)
32
32
  end
33
33
 
34
34
  # Log any one or more of a message, an exception and structured data as DEBUG.
@@ -39,42 +39,42 @@ module Ougai
39
39
  # @yieldreturn [String|Exception|Object|Array] Any one or more of former parameters
40
40
  # @return [Boolean] true
41
41
  def debug(message = nil, ex = nil, data = nil, &block)
42
- add(DEBUG, message, ex, data, &block)
42
+ _log(DEBUG, message, ex, data, &block)
43
43
  end
44
44
 
45
45
  # Log any one or more of a message, an exception and structured data as INFO.
46
46
  # @return [Boolean] true
47
47
  # @see Logging#debug
48
48
  def info(message = nil, ex = nil, data = nil, &block)
49
- add(INFO, message, ex, data, &block)
49
+ _log(INFO, message, ex, data, &block)
50
50
  end
51
51
 
52
52
  # Log any one or more of a message, an exception and structured data as WARN.
53
53
  # @return [Boolean] true
54
54
  # @see Logging#debug
55
55
  def warn(message = nil, ex = nil, data = nil, &block)
56
- add(WARN, message, ex, data, &block)
56
+ _log(WARN, message, ex, data, &block)
57
57
  end
58
58
 
59
59
  # Log any one or more of a message, an exception and structured data as ERROR.
60
60
  # @return [Boolean] true
61
61
  # @see Logging#debug
62
62
  def error(message = nil, ex = nil, data = nil, &block)
63
- add(ERROR, message, ex, data, &block)
63
+ _log(ERROR, message, ex, data, &block)
64
64
  end
65
65
 
66
66
  # Log any one or more of a message, an exception and structured data as FATAL.
67
67
  # @return [Boolean] true
68
68
  # @see Logging#debug
69
69
  def fatal(message = nil, ex = nil, data = nil, &block)
70
- add(FATAL, message, ex, data, &block)
70
+ _log(FATAL, message, ex, data, &block)
71
71
  end
72
72
 
73
73
  # Log any one or more of a message, an exception and structured data as UNKNOWN.
74
74
  # @return [Boolean] true
75
75
  # @see Logging#debug
76
76
  def unknown(message = nil, ex = nil, data = nil, &block)
77
- add(UNKNOWN, message, ex, data, &block)
77
+ _log(UNKNOWN, message, ex, data, &block)
78
78
  end
79
79
 
80
80
  # Whether the current severity level allows for logging TRACE.
@@ -91,14 +91,18 @@ module Ougai
91
91
  # @param data [Object] Any structured data
92
92
  # @yieldreturn [String|Exception|Object|Array] Any one or more of former parameters
93
93
  # @return [Boolean] true
94
- def add(severity, *args)
94
+ def add(severity, message = nil, ex = nil, data = nil, &block)
95
+ _log(severity, message, ex, data, &block)
96
+ end
97
+
98
+ alias log add
99
+
100
+ def _log(severity, *args)
95
101
  severity ||= UNKNOWN
96
102
  return true if level > severity
97
103
  append(severity, block_given? ? yield : args)
98
104
  end
99
105
 
100
- alias log add
101
-
102
106
  # @private
103
107
  def chain(_severity, _args, _fields, _hooks)
104
108
  raise NotImplementedError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ougai
4
- VERSION = '1.9.0'
4
+ VERSION = '1.9.1'
5
5
  end
@@ -42,22 +42,30 @@ describe Ougai::Logging do
42
42
  context 'severity is specified level' do
43
43
  it 'calls append with specified level' do
44
44
  data = double('data')
45
- expect(subject).to receive(:append).with(::Logger::Severity::DEBUG, ['debug message', data])
45
+ expect(subject).to receive(:append).with(::Logger::Severity::DEBUG, ['debug message', data, nil])
46
46
  subject.add(::Logger::Severity::DEBUG, 'debug message', data)
47
47
  end
48
48
  end
49
49
 
50
50
  context 'severity is nil' do
51
51
  it 'calls append with UNKNOWN level' do
52
- expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message'])
52
+ expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message', nil, nil])
53
53
  subject.add(nil, 'message')
54
54
  end
55
55
  end
56
56
 
57
- context 'block given' do
58
- it 'calls append with yielded arguments' do
59
- expect(subject).to receive(:append).with(::Logger::Severity::WARN, ['block message'])
60
- subject.log(::Logger::Severity::WARN) { ['block message'] }
57
+ context 'with block that yields message' do
58
+ it 'calls append with yielded message' do
59
+ expect(subject).to receive(:append).with(::Logger::Severity::WARN, 'block message')
60
+ subject.add(::Logger::Severity::WARN) { 'block message' }
61
+ end
62
+ end
63
+
64
+ context 'with block that yields array' do
65
+ it 'calls append with yielded array' do
66
+ data = double('data')
67
+ expect(subject).to receive(:append).with(::Logger::Severity::WARN, ['block message', data])
68
+ subject.add(::Logger::Severity::WARN) { ['block message', data] }
61
69
  end
62
70
  end
63
71
  end
@@ -66,19 +74,19 @@ describe Ougai::Logging do
66
74
  context 'severity is specified' do
67
75
  it 'calls append with specified level' do
68
76
  ex = Exception.new
69
- expect(subject).to receive(:append).with(::Logger::Severity::FATAL, ['fatal message', ex])
77
+ expect(subject).to receive(:append).with(::Logger::Severity::FATAL, ['fatal message', ex, nil])
70
78
  subject.log(::Logger::Severity::FATAL, 'fatal message', ex)
71
79
  end
72
80
  end
73
81
 
74
82
  context 'severity is nil' do
75
83
  it 'calls append with UNKNOWN level' do
76
- expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message'])
84
+ expect(subject).to receive(:append).with(::Logger::Severity::UNKNOWN, ['message', nil, nil])
77
85
  subject.log(nil, 'message')
78
86
  end
79
87
  end
80
88
 
81
- context 'block given' do
89
+ context 'with block' do
82
90
  it 'calls append with yielded arguments' do
83
91
  ex = Exception.new
84
92
  data = double('data')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ougai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshimitsu Takahashi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-10 00:00:00.000000000 Z
11
+ date: 2021-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj