leafy-logger 0.5.0-java → 0.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/leafy/logger/factory.rb +2 -1
- data/lib/leafy/logger/proxy_logger.rb +30 -0
- data/lib/leafy/logger/version.rb +1 -1
- data/spec/factory_spec.rb +6 -2
- data/spec/proxy_logger_spec.rb +27 -0
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ed92ed106adeed17aa9a89dbc0a4610c591051
|
4
|
+
data.tar.gz: b3713e451293841fcf2ecafa8b39aaea10f00e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f24e22c6645281ca38959272d9059682d71363a3d43372a0b664c9f849b0e594baa53c9b844b5c3d091a3ee6d855bc43e9be426d379aae911d027ddb3e876ab
|
7
|
+
data.tar.gz: 32c13ca48b9a4585dd8777ecd096862ac4a0a6e882b199bad6687e240d5c4ce7e2099dc0fbaedbae3fa393bcb65e5cd6e64198407ca47eaa065cea2c4d6f31d1
|
data/lib/leafy/logger/factory.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'leafy/logger'
|
2
2
|
require 'leafy/logger/appender_factories'
|
3
|
+
require 'leafy/logger/proxy_logger'
|
3
4
|
require 'yaml'
|
4
5
|
require 'stringio'
|
5
6
|
require 'jruby/synchronized'
|
@@ -22,7 +23,7 @@ module Leafy
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def self.get_logger( name )
|
25
|
-
org.slf4j.LoggerFactory.get_logger name
|
26
|
+
ProxyLogger.new( org.slf4j.LoggerFactory.get_logger( name ) )
|
26
27
|
end
|
27
28
|
|
28
29
|
def self.bootstrap
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Leafy
|
2
|
+
module Logger
|
3
|
+
class ProxyLogger
|
4
|
+
def initialize(logger)
|
5
|
+
@logger = logger
|
6
|
+
end
|
7
|
+
|
8
|
+
def method_missing(sym, *args, &block)
|
9
|
+
if @logger.respond_to?(sym)
|
10
|
+
@logger.send(sym, *args)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def respond_to?(sym, include_private = false)
|
17
|
+
@logger.respond_to?(sym, include_private)
|
18
|
+
end
|
19
|
+
|
20
|
+
# slf4j does not include the fatal level
|
21
|
+
def fatal(*args)
|
22
|
+
error(*args)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Provided for compatibility with the stdlib Logger interface. Not used, since the logger
|
26
|
+
# that we're proxying has a much better formatter! (Right?)
|
27
|
+
attr_accessor :formatter
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/leafy/logger/version.rb
CHANGED
data/spec/factory_spec.rb
CHANGED
@@ -48,7 +48,7 @@ describe Leafy::Logger::Factory do
|
|
48
48
|
subject.level = 'INFO'
|
49
49
|
expect( subject.level ).to eq 'INFO'
|
50
50
|
|
51
|
-
subject.level 'DEBUG'
|
51
|
+
subject.level 'DEBUG'
|
52
52
|
expect( subject.level ).to eq 'DEBUG'
|
53
53
|
end
|
54
54
|
|
@@ -61,7 +61,7 @@ describe Leafy::Logger::Factory do
|
|
61
61
|
logger2.debug 'debug2'
|
62
62
|
logger2.info 'good'
|
63
63
|
logger2.warn 'good'
|
64
|
-
|
64
|
+
|
65
65
|
subject.stop
|
66
66
|
|
67
67
|
lines = File.read( log ).split( /\n/ )
|
@@ -124,6 +124,10 @@ describe Leafy::Logger::Factory do
|
|
124
124
|
|
125
125
|
end
|
126
126
|
|
127
|
+
it 'uses ProxyLoggers' do
|
128
|
+
expect( logger1 ).to be_a Leafy::Logger::ProxyLogger
|
129
|
+
end
|
130
|
+
|
127
131
|
it 'fails on missing yaml configuration' do
|
128
132
|
expect {Leafy::Logger::Factory.new_from_yaml( yaml + '.gone' ) }.to raise_error( Exception )
|
129
133
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'setup'
|
2
|
+
require 'leafy/logger/proxy_logger'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
describe Leafy::Logger::ProxyLogger do
|
6
|
+
subject(:proxy) { described_class.new(logger) }
|
7
|
+
let(:logger) { instance_double(Logger, debug: debug_result, error: error_result) }
|
8
|
+
let(:debug_result) { 'debug result' }
|
9
|
+
let(:error_result) { 'error result' }
|
10
|
+
|
11
|
+
describe '#method_missing' do
|
12
|
+
it 'should call the logger when given a method that exists' do
|
13
|
+
expect(proxy.debug).to eq debug_result
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should raise a NameError when given a method that does not exist' do
|
17
|
+
expect { proxy.lol }.to raise_error(NameError)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#fatal' do
|
22
|
+
it 'should call #error' do
|
23
|
+
expect(proxy.fatal(:a)).to eq error_result
|
24
|
+
expect(logger).to have_received(:error).with(:a)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leafy-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- christian meier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jar-dependencies
|
15
15
|
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.1.8
|
20
20
|
requirement: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
|
-
- - ~>
|
22
|
+
- - "~>"
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: 0.1.8
|
25
25
|
prerelease: false
|
@@ -28,26 +28,26 @@ dependencies:
|
|
28
28
|
name: leafy-metrics
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.6.0
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- - ~>
|
36
|
+
- - "~>"
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.
|
38
|
+
version: 0.6.0
|
39
39
|
prerelease: false
|
40
40
|
type: :runtime
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.1'
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
|
-
- - ~>
|
50
|
+
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '3.1'
|
53
53
|
prerelease: false
|
@@ -56,12 +56,12 @@ dependencies:
|
|
56
56
|
name: yard
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.8.7
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - ~>
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: 0.8.7
|
67
67
|
prerelease: false
|
@@ -70,12 +70,12 @@ dependencies:
|
|
70
70
|
name: rake
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '10.2'
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - ~>
|
78
|
+
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '10.2'
|
81
81
|
prerelease: false
|
@@ -87,7 +87,7 @@ executables: []
|
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
|
-
- .gitignore
|
90
|
+
- ".gitignore"
|
91
91
|
- Gemfile
|
92
92
|
- LICENSE
|
93
93
|
- README.md
|
@@ -98,10 +98,12 @@ files:
|
|
98
98
|
- lib/leafy/logger.rb
|
99
99
|
- lib/leafy/logger/appender_factories.rb
|
100
100
|
- lib/leafy/logger/factory.rb
|
101
|
+
- lib/leafy/logger/proxy_logger.rb
|
101
102
|
- lib/leafy/logger/version.rb
|
102
103
|
- spec/appender_factories_spec.rb
|
103
104
|
- spec/factory_spec.rb
|
104
105
|
- spec/logging.yml
|
106
|
+
- spec/proxy_logger_spec.rb
|
105
107
|
- spec/setup.rb
|
106
108
|
homepage: https://github.com/lookout/leafy
|
107
109
|
licenses:
|
@@ -113,12 +115,12 @@ require_paths:
|
|
113
115
|
- lib
|
114
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
117
|
requirements:
|
116
|
-
- -
|
118
|
+
- - ">="
|
117
119
|
- !ruby/object:Gem::Version
|
118
120
|
version: '0'
|
119
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
122
|
requirements:
|
121
|
-
- -
|
123
|
+
- - ">="
|
122
124
|
- !ruby/object:Gem::Version
|
123
125
|
version: '0'
|
124
126
|
requirements:
|