Skip to content

Commit

Permalink
default procid to pid
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Tribone committed Sep 29, 2015
1 parent 9237bf7 commit 6b861ac
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require "bundler/gem_tasks"
2 changes: 1 addition & 1 deletion lib/syslogger/formatter/rfc5424.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(appname = nil, procid = nil, msgid = nil, facility = nil)
super()

@msgid = format(msgid, 32)
@procid = format(procid, 128)
@procid = format(procid || Process.pid.to_s, 128)
@appname = format(appname, 48)

self.facility = facility || :local7
Expand Down
4 changes: 2 additions & 2 deletions spec/syslogger/formatter/rfc5424_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
describe SysLogger::Formatter::RFC5424 do
its(:msgid) { is_expected.to eq "-" }
its(:procid) { is_expected.to eq "-" }
its(:procid) { is_expected.to eq Process.pid.to_s }
its(:appname) { is_expected.to eq "-" }
its(:facility) { is_expected.to eq 23 }

describe "#call" do
it "generates Format" do
expect(subject.call(::Logger::INFO, DateTime.now, "Prog", "Message")).
to match /<190>1.* - - Prog \[meta x-group=".*"\] Message/
to match /<190>1.* - #{Process.pid} Prog \[meta x-group=".*"\] Message/
end
end
end
2 changes: 1 addition & 1 deletion spec/syslogger/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
it "logs exceptions" do
subject.error StandardError.new("foobar")
expect(io.string).to match(
/<187>1.* - - - \[meta x-group=".*"\] foobar \(StandardError\)/)
/<187>1.* - #{Process.pid} - \[meta x-group=".*"\] foobar \(StandardError\)/)
end
end
4 changes: 3 additions & 1 deletion syslogger.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "syslogger5424"
spec.version = "0.2.0"
spec.version = "0.3.0"
spec.date = "2014-09-30"
spec.summary = "Logging via syslog using RFC 5424 format"
spec.authors = ["EasyPost"]
Expand All @@ -13,6 +13,8 @@ Gem::Specification.new do |spec|

spec.add_dependency "mono_logger"

spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "rspec-its"
end

0 comments on commit 6b861ac

Please sign in to comment.