-
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 #59 from dwbutler/syslog
Support for logging to syslog
- Loading branch information
Showing
5 changed files
with
106 additions
and
14 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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
input { | ||
syslog { | ||
codec => json_lines | ||
} | ||
} | ||
output { | ||
stdout { | ||
codec => json_lines | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'logstash-logger' | ||
|
||
describe LogStashLogger do | ||
context "Syslog" do | ||
let(:program_name) { "MyApp" } | ||
let(:facility) { Syslog::LOG_LOCAL0 } | ||
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 | ||
expect(syslog).to receive(:log) | ||
subject.info("test") | ||
end | ||
|
||
it "sets the syslog identity" do | ||
expect(syslog.ident).to eq(program_name) | ||
end | ||
|
||
it "sets the default facility if supported" do | ||
expect(subject.facility).to eq(facility) if subject.respond_to?(:facility) | ||
end | ||
end | ||
end |