lookout-rack-utils 3.2.0.19 → 3.3.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODk5NmIxNjM0OGY5MjUxZGVhZmIyNmVjYjMyMTM2NjU0YzMzZTMxMw==
4
+ NjFjZjM4ZTdlZTM0OTM4ZGI4ZGE0NTRlNTFiODlmYTQ4NzgxNjk0Nw==
5
5
  data.tar.gz: !binary |-
6
- ZDZlZWE5ZmNhZjA2NDJmZTIzMGZjMjJhNDIzMWI3YzYwZjNlMzE0NA==
6
+ MmU1MTc1YWYzOTljY2Y0ZTRhNjgyNTRhMTlhMmEyMmEyZDRlZmJmOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGFiY2RkN2YzNmIwZGQ3ZTBjMjNiMzczNTMyNmYwMGYyM2MxOTkyYmY4NjBk
10
- NDYzMWEzNGY2MWViYWM2ZGRhZWMwMjI4NWYzNDI1NzI2YWMyN2JjOGE3Mzll
11
- YTI0ZmRhODc0ZjIwOWFhNThlOGM3YTU1ZDNmZGM4ZjFhODViZmM=
9
+ MjQ1ZmJiYTI5ZDljYTczZDgwMTA3YjQ1NGNiNGY3YjA5OGIzNDhmMWExOTVj
10
+ OWM3NDRiN2NjM2QxYmRlYTNhNGE3NzdjYmU5MjEzZTk5YmJkMzNlMjIwZTU3
11
+ MWMwZDNiNjU3MjQ2OGNjNDBiMjUwYjAzZWY5MGUyNTAwNTYzNTM=
12
12
  data.tar.gz: !binary |-
13
- MDhjZDRmOWQ4M2RmNTg4Yjc1NDg1ZDQ2OTY3MGEwZTQ1NGJjMTgxYmRhN2Vj
14
- Y2NmOTkxZTM0NGZkYmQ4M2VlYzQwOTE0YjRlZjZlZDhiYzc0Mzg2ZTFkNjk2
15
- OTMwNzJiZTM5ZjJkYTQ4M2VkM2VkZThhYWRlNDg0MzA2NzJhMDM=
13
+ Y2UwOTVkMTM4YjMwODdhYzVmY2I2M2FlNDlmMTA4Yjc4NjBkYzgxOWI2M2Iw
14
+ MGFjOGYwOWJhZTA1MTBmNGRjYTc4MzRiY2RmZDU3YjJhNmNlMjg1NTc1MTY5
15
+ NWQxM2YwMjZjZDc2NDEzYTFjZTBkZTA1NmUyMGI2YWRkZjc0ODM=
@@ -78,9 +78,7 @@ module Lookout::Rack::Utils
78
78
  @logger.level = Log4r::OFF
79
79
  end
80
80
 
81
- @outputter = FileOutputter.new("#{logger_name.to_s}fileoutput",
82
- {:filename => configatron.logging.file,
83
- :trunc => false})
81
+ @outputter = build_outputter(logger_name)
84
82
  @logger.trace = true
85
83
  @outputter.formatter = LookoutFormatter
86
84
  @logger.outputters = @outputter
@@ -104,5 +102,17 @@ module Lookout::Rack::Utils
104
102
  @logger.send(allow_logging, *args)
105
103
  end
106
104
  end
105
+
106
+ # Build and return the appropriate Outputter
107
+ def build_outputter(logger_name)
108
+ if configatron.logging.file =~ /^stdout$/i
109
+ StdoutOutputter.new("#{logger_name}stdout")
110
+ else
111
+ FileOutputter.new("#{logger_name}fileoutput",
112
+ {:filename => configatron.logging.file,
113
+ :trunc => false})
114
+ end
115
+ end
116
+ private :build_outputter
107
117
  end
108
118
  end
@@ -1,7 +1,7 @@
1
1
  module Lookout
2
2
  module Rack
3
3
  module Utils
4
- VERSION = "3.2.0"
4
+ VERSION = "3.3.0"
5
5
  end
6
6
  end
7
7
  end
data/spec/log_spec.rb CHANGED
@@ -6,10 +6,11 @@ require 'configatron'
6
6
  describe Lookout::Rack::Utils::Log do
7
7
  subject(:log) { described_class.instance }
8
8
  subject(:log_message) { 'foo' }
9
+ let(:filename) { "log" }
9
10
 
10
- before :all do
11
+ before :each do
11
12
  configatron.logging.enabled = true
12
- configatron.logging.file = "log"
13
+ allow(configatron.logging).to receive(:file).and_return(filename)
13
14
  end
14
15
 
15
16
  describe '.debug' do
@@ -65,6 +66,26 @@ describe Lookout::Rack::Utils::Log do
65
66
  end
66
67
  end
67
68
  end
69
+
70
+ # Private method but tested since we can't otherwise test configuration of the singleton
71
+ describe "#build_outputter" do
72
+ let(:logger_name) { "logger" }
73
+ subject(:build_outputter) { log.send(:build_outputter, logger_name)}
74
+
75
+ context "when logging to a file" do
76
+ let(:filename) { "foo.log" }
77
+ it "should use a FileOutputter" do
78
+ expect(subject).to be_a(Log4r::FileOutputter)
79
+ end
80
+ end
81
+
82
+ context "when logging to STDOUT" do
83
+ let(:filename) { "STDOUT" }
84
+ it "should use a StdoutOutputter" do
85
+ expect(subject).to be_a(Log4r::StdoutOutputter)
86
+ end
87
+ end
88
+ end
68
89
  end
69
90
 
70
91
  describe Lookout::Rack::Utils::Log::LookoutFormatter do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout-rack-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.19
4
+ version: 3.3.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-01 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler