buffered_syslogger 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -3
- data/lib/buffered_syslogger.rb +1 -1
- data/spec/buffered_syslogger_spec.rb +17 -19
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
= BufferedSyslogger
|
2
2
|
|
3
3
|
A drop-in replacement for the Rails 3 default BufferedLogger library,
|
4
|
-
that logs to syslog instead of a log file. Builds on the
|
4
|
+
that logs to syslog instead of a log file. Builds on the
|
5
|
+
{syslogger}[http://github.com/crohr/syslogger] gem.
|
5
6
|
|
6
7
|
== Installation
|
7
8
|
|
8
|
-
Put
|
9
|
+
Put this into your Gemfile:
|
9
10
|
|
10
11
|
gem 'buffered_syslogger'
|
11
12
|
|
@@ -24,7 +25,8 @@ Put it into your Gemfile:
|
|
24
25
|
|
25
26
|
== Copyright
|
26
27
|
|
27
|
-
Copyright (c) 2010 László
|
28
|
+
Copyright (c) 2010 László Bácsi, Secret Sauce Partners, Inc.
|
29
|
+
|
28
30
|
Copyright (c) 2010 Cyril, INRIA Rennes-Bretagne Atlantique.
|
29
31
|
|
30
32
|
See LICENSE for details.
|
data/lib/buffered_syslogger.rb
CHANGED
@@ -67,7 +67,7 @@ class BufferedSyslogger < ActiveSupport::BufferedLogger
|
|
67
67
|
Syslog.open(@ident, @options, @facility) do |s|
|
68
68
|
s.mask = Syslog::LOG_UPTO(MAPPING[@level])
|
69
69
|
old_buffer.each do |severity, message|
|
70
|
-
message.split(/[\r\f\n]/).each { |m| s.log(MAPPING[severity], m) }
|
70
|
+
message.split(/[\r\f\n]/).each { |m| s.log(MAPPING[severity], m.gsub('%', '%%')) }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -19,33 +19,31 @@ describe BufferedSyslogger do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
%w{debug info warn error fatal unknown}.each do |logger_method|
|
22
|
-
it
|
23
|
-
|
24
|
-
end
|
22
|
+
it { should respond_to :"#{logger_method}" }
|
23
|
+
it { should respond_to :"#{logger_method}?" }
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
it "should escape % characters" do
|
27
|
+
Syslog.should_receive(:open).and_yield(syslog)
|
28
|
+
syslog.should_receive(:log).with(Syslog::LOG_INFO, "IE6 is at 5.6%% out of 31.1%% total IE share")
|
29
|
+
subject.info "IE6 is at 5.6% out of 31.1% total IE share"
|
31
30
|
end
|
32
31
|
|
33
|
-
describe
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
it "should correctly log" do
|
41
|
-
Syslog.should_receive(:open).with("my_app", Syslog::LOG_PID, Syslog::LOG_USER).and_yield(syslog)
|
32
|
+
describe '#add' do
|
33
|
+
subject { BufferedSyslogger.new("my_app", Syslog::LOG_PID, Syslog::LOG_USER) }
|
34
|
+
|
35
|
+
it { should respond_to(:add) }
|
36
|
+
|
37
|
+
it "should correctly log a simple message" do
|
38
|
+
Syslog.should_receive(:open).and_yield(syslog)
|
42
39
|
syslog.should_receive(:log).with(Syslog::LOG_INFO, "message")
|
43
|
-
|
40
|
+
subject.add(Logger::INFO, "message")
|
44
41
|
end
|
42
|
+
|
45
43
|
it "should take the message from the block if :message is nil" do
|
46
|
-
Syslog.should_receive(:open).
|
44
|
+
Syslog.should_receive(:open).and_yield(syslog)
|
47
45
|
syslog.should_receive(:log).with(Syslog::LOG_INFO, "my message")
|
48
|
-
|
46
|
+
subject.add(Logger::INFO) { "my message" }
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buffered_syslogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- !binary |
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-10-
|
21
|
+
date: 2010-10-12 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|