alephant-logger 1.1.0 → 1.1.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
  SHA1:
3
- metadata.gz: 6af5157424ed22f237bd8bb83fc42ba89578c0ab
4
- data.tar.gz: d4653f7f7f37671455c5f15264b447c871c7f35e
3
+ metadata.gz: d5d1499280f31079a470dd60e74786a9393802b3
4
+ data.tar.gz: 371124eae62711cdedeadf70e1f6e5827ece2e1a
5
5
  SHA512:
6
- metadata.gz: 9abf8bda98890e6c93941b8c26f32a272584907a87230cafea3f1a01b06b07949721871cc3fea0c142bb6d15eb702eea760b2141ac1b3325288b6d3a3d25d461
7
- data.tar.gz: 6b961e7ae7ed9797ee165ae930ddd29f8a56a6cd63695898f510c94c925dacd74bd97b60b1e9c269b1e9dcd1b12e4a86d6f1345091798c88321f3c8f72e2d9f7
6
+ metadata.gz: 643fa7bab726821bef7a1b6e2ad9c280e75679251f72879fd6c0817a039a3980b3c08a06b164c03ddacdd0383066b45f43a71564919d76689d959a815f5e2616
7
+ data.tar.gz: f660dee91ea4db95ec0ace00c252717da051e75d70374d62b8908c7ceb696f86286c81d6e0e1d733bba9447b3bfafe9ed5c96410303eecafa33e2e15ae78f81e
@@ -1,33 +1,17 @@
1
- require 'alephant/logger/version'
2
- require 'logger'
1
+ require "alephant/logger/version"
2
+ require "alephant/logger_factory"
3
+ require "logger"
3
4
 
4
5
  module Alephant
5
6
  module Logger
6
- def self.create(drivers = [])
7
- Logger.new drivers
8
- end
9
-
10
- class Logger
11
- def initialize(drivers)
12
- @drivers = drivers << ::Logger.new(STDOUT)
13
- end
14
-
15
- def method_missing(name, *args)
16
- drivers.each do |driver|
17
- driver.send(name, *args) if driver.respond_to? name
18
- end
19
- end
7
+ @@logger = Alephant::LoggerFactory.create []
20
8
 
21
- def respond_to?(name)
22
- drivers.any? do |driver|
23
- driver.respond_to?(name) || super
24
- end
25
- end
26
-
27
- private
9
+ def logger
10
+ @@logger
11
+ end
28
12
 
29
- attr_reader :drivers
13
+ def self.setup(*drivers)
14
+ @@logger = Alephant::LoggerFactory.create(drivers.flatten)
30
15
  end
31
16
  end
32
17
  end
33
-
@@ -0,0 +1,25 @@
1
+ module Alephant
2
+ module Logger
3
+ class Base
4
+ def initialize(drivers)
5
+ @drivers = drivers << ::Logger.new(STDOUT)
6
+ end
7
+
8
+ def method_missing(name, *args)
9
+ drivers.each do |driver|
10
+ driver.send(name, *args) if driver.respond_to? name
11
+ end
12
+ end
13
+
14
+ def respond_to?(name)
15
+ drivers.any? do |driver|
16
+ driver.respond_to?(name) || super
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :drivers
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Logger
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -0,0 +1,9 @@
1
+ require "alephant/logger/base"
2
+
3
+ module Alephant
4
+ module LoggerFactory
5
+ def self.create(drivers)
6
+ Alephant::Logger::Base.new drivers
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe Alephant::Logger::Base do
4
+ describe "#info" do
5
+ context "no logger drivers given" do
6
+ subject { Alephant::Logger::Base.new [] }
7
+
8
+ specify do
9
+ expect_any_instance_of(::Logger).to receive(:info).with "msg"
10
+
11
+ subject.info "msg"
12
+ end
13
+ end
14
+
15
+ context "logger drivers given" do
16
+ subject { Alephant::Logger::Base.new [driver] }
17
+
18
+ let(:driver) { double }
19
+
20
+ it "responding drivers receive method calls" do
21
+ expect(driver).to receive(:metric).with("foo")
22
+
23
+ subject.metric("foo")
24
+ end
25
+
26
+ it "::Logger is always used" do
27
+ expect_any_instance_of(::Logger).to receive(:info).with "foo"
28
+
29
+ subject.info "foo"
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,41 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Alephant::Logger do
4
- describe ".create" do
4
+ describe ".setup" do
5
5
  specify do
6
- expect(subject.create).to be_a Alephant::Logger::Logger
7
- end
8
- end
9
- end
10
-
11
- describe Alephant::Logger::Logger do
12
- describe "#info" do
13
- context "no logger drivers given" do
14
- subject { Alephant::Logger::Logger.new [] }
15
-
16
- specify do
17
- expect_any_instance_of(::Logger).to receive(:info).with "msg"
18
-
19
- subject.info "msg"
20
- end
21
- end
22
-
23
- context "logger drivers given" do
24
- subject { Alephant::Logger::Logger.new [driver] }
25
-
26
- let(:driver) { double }
27
-
28
- it "responding drivers receive method calls" do
29
- expect(driver).to receive(:metric).with("foo")
30
-
31
- subject.metric("foo")
32
- end
33
-
34
- it "::Logger is always used" do
35
- expect_any_instance_of(::Logger).to receive(:info).with "foo"
36
-
37
- subject.info "foo"
38
- end
6
+ expect(subject.setup).to be_a Alephant::Logger::Base
39
7
  end
40
8
  end
41
9
  end
@@ -1,5 +1,4 @@
1
- $: << File.join(File.dirname(__FILE__),"..", "lib")
2
-
3
- require 'pry'
4
- require 'alephant/logger'
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib")
5
2
 
3
+ require "pry"
4
+ require "alephant/logger"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alephant-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Kenny
@@ -153,7 +153,10 @@ files:
153
153
  - Rakefile
154
154
  - alephant-logger.gemspec
155
155
  - lib/alephant/logger.rb
156
+ - lib/alephant/logger/base.rb
156
157
  - lib/alephant/logger/version.rb
158
+ - lib/alephant/logger_factory.rb
159
+ - spec/logger_base_spec.rb
157
160
  - spec/logger_spec.rb
158
161
  - spec/spec_helper.rb
159
162
  homepage: ''
@@ -181,5 +184,6 @@ signing_key:
181
184
  specification_version: 4
182
185
  summary: Logger functionality for Alephant
183
186
  test_files:
187
+ - spec/logger_base_spec.rb
184
188
  - spec/logger_spec.rb
185
189
  - spec/spec_helper.rb