forked from dwbutler/logstash-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
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 dwbutler#131 from AlexeyKrasnoperov/bugfix/allow-t…
…ype-to-be-a-string-for-multi_logger-and-syslog Allow type to be a string for multi_logger and syslog
- Loading branch information
Showing
3 changed files
with
19 additions
and
8 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
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,25 +1,34 @@ | ||
require 'logstash-logger' | ||
|
||
describe LogStashLogger do | ||
context "Syslog" do | ||
let(:program_name) { "MyApp" } | ||
let(:facility) { 128 } #Syslog::LOG_LOCAL0 } | ||
let(:program_name) { 'MyApp' } | ||
let(:facility) { 128 } #Syslog::LOG_LOCAL0 } | ||
|
||
context 'Syslog' do | ||
subject { LogStashLogger.new(type: :syslog, program_name: program_name, facility: facility) } | ||
let(:syslog) { subject.class.class_variable_get(:@@syslog) } | ||
|
||
it { is_expected.to be_a Syslog::Logger } | ||
|
||
it "writes formatted messages to syslog" do | ||
it 'writes formatted messages to syslog' do | ||
expect(syslog).to receive(:log) | ||
subject.info("test") | ||
subject.info('test') | ||
end | ||
|
||
it "sets the syslog identity" do | ||
it 'sets the syslog identity' do | ||
expect(syslog.ident).to eq(program_name) | ||
end | ||
|
||
it "sets the default facility if supported" do | ||
it 'sets the default facility if supported' do | ||
expect(subject.facility).to eq(facility) if subject.respond_to?(:facility) | ||
end | ||
end | ||
|
||
context 'When logger type is a string' do | ||
subject { LogStashLogger.new(type: 'syslog', program_name: program_name, facility: facility) } | ||
|
||
it 'creates syslog logger even if type is not a symbol' do | ||
expect(subject).to be_a(LogStashLogger) | ||
end | ||
end | ||
end |