syslogger 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,6 +15,7 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
15
15
  end
16
16
 
17
17
  Rake::RDocTask.new do |rdoc|
18
+ require 'syslogger'
18
19
  rdoc.rdoc_dir = 'rdoc'
19
20
  rdoc.title = "syslogger #{Syslogger::VERSION}"
20
21
  rdoc.rdoc_files.include('README*')
data/lib/syslogger.rb CHANGED
@@ -3,7 +3,7 @@ require 'logger'
3
3
 
4
4
  class Syslogger
5
5
 
6
- VERSION = "1.2.1"
6
+ VERSION = "1.2.2"
7
7
 
8
8
  attr_reader :level, :ident, :options, :facility
9
9
 
@@ -71,7 +71,9 @@ class Syslogger
71
71
  progname ||= @ident
72
72
  Syslog.open(progname, @options, @facility) { |s|
73
73
  s.mask = Syslog::LOG_UPTO(MAPPING[@level])
74
- s.log(MAPPING[severity], (message || block.call).to_s)
74
+ # substitute '%' for '%%' before logging
75
+ # so that syslog won't complain about malformed characters
76
+ s.log(MAPPING[severity], (message || block.call).to_s.gsub(/%/, '%%'))
75
77
  }
76
78
  end
77
79
 
@@ -51,6 +51,12 @@ describe "Syslogger" do
51
51
  syslog.should_receive(:log).with(Syslog::LOG_INFO, "message")
52
52
  @logger.add(Logger::INFO, "message", "progname") { "my message" }
53
53
  end
54
+
55
+ it "should substitute '%' for '%%' before adding the :message" do
56
+ Syslog.stub(:open).and_yield(syslog=mock("syslog", :mask= => true))
57
+ syslog.should_receive(:log).with(Syslog::LOG_INFO, "%%me%%ssage%%")
58
+ @logger.add(Logger::INFO, "%me%ssage%")
59
+ end
54
60
  end # describe "add"
55
61
 
56
62
  describe ":level? methods" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 1
9
- version: 1.2.1
8
+ - 2
9
+ version: 1.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Cyril Rohr
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-05 00:00:00 +01:00
17
+ date: 2011-01-06 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency