-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from swiftype/alechoey/configurable_logger_class
Allow user configuration of the logger class
- Loading branch information
Showing
2 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
require 'logstash-logger' | ||
|
||
describe LogStashLogger do | ||
describe ".new" do | ||
it "returns a Logger instance" do | ||
describe '.new' do | ||
it 'returns a Logger instance' do | ||
expect(LogStashLogger.new(type: :stdout)).to be_a ::Logger | ||
end | ||
|
||
context "type: :multi_logger" do | ||
context 'type: :multi_logger' do | ||
it "returns an instance of LogStashLogger::MultiLogger" do | ||
expect(LogStashLogger.new(type: :multi_logger)).to be_a LogStashLogger::MultiLogger | ||
end | ||
|
||
it "merges top level configuration into each logger" do | ||
it 'merges top level configuration into each logger' do | ||
logger = LogStashLogger.new(type: :multi_logger, port: 1234, outputs: [ { type: :tcp }, { type: :udp } ]) | ||
logger.loggers.each do |logger| | ||
expect(logger.device.port).to eq(1234) | ||
end | ||
end | ||
end | ||
|
||
context 'logger_class: CustomLogger' do | ||
class CustomLogger < Logger; end | ||
|
||
it 'should create a logger of the specified class' do | ||
expect(LogStashLogger.new(type: :stdout, :logger_class => CustomLogger)).to be_a CustomLogger | ||
end | ||
end | ||
end | ||
end |