syslogger 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/syslogger.rb +9 -7
- data/spec/syslogger_spec.rb +34 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d44b66d0d0f21132b492ac60cca50af4b3af74
|
4
|
+
data.tar.gz: f352bce8e245b7a0766c8f487f1b90cffd1c7aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 561f991cf10f575fbcc79780af70ef52f586895ce0aa232d1405ddb957cb9b17847d41b8d02b31108700670ca62ed917a74d4b18567f90f5bd7d6033c447f93e
|
7
|
+
data.tar.gz: 37c03b6e2241578271de3027587fe06a96c938a0b540a04882c6de58af3b9220964179cd033c38489b9d340cda977dd16e79396f3536ba7c2ceb7510719349f5
|
data/lib/syslogger.rb
CHANGED
@@ -4,7 +4,9 @@ require 'thread'
|
|
4
4
|
|
5
5
|
class Syslogger
|
6
6
|
|
7
|
-
VERSION = "1.6.
|
7
|
+
VERSION = "1.6.3"
|
8
|
+
|
9
|
+
MUTEX = Mutex.new
|
8
10
|
|
9
11
|
attr_reader :level, :ident, :options, :facility, :max_octets
|
10
12
|
attr_accessor :formatter
|
@@ -47,7 +49,6 @@ class Syslogger
|
|
47
49
|
@options = options || (Syslog::LOG_PID | Syslog::LOG_CONS)
|
48
50
|
@facility = facility
|
49
51
|
@level = Logger::INFO
|
50
|
-
@mutex = Mutex.new
|
51
52
|
@formatter = proc do |severity, datetime, progname, msg|
|
52
53
|
msg
|
53
54
|
end
|
@@ -90,12 +91,13 @@ class Syslogger
|
|
90
91
|
message, progname = progname, nil
|
91
92
|
end
|
92
93
|
progname ||= @ident
|
93
|
-
|
94
|
-
|
94
|
+
mask = Syslog::LOG_UPTO(MAPPING[@level])
|
95
|
+
communication = clean(message || block && block.call)
|
96
|
+
formatted_communication = formatter.call([severity], Time.now, progname, communication)
|
97
|
+
|
98
|
+
MUTEX.synchronize do
|
95
99
|
Syslog.open(progname, @options, @facility) do |s|
|
96
|
-
s.mask =
|
97
|
-
communication = clean(message || block && block.call)
|
98
|
-
formatted_communication = formatter.call([severity], Time.now, progname, communication)
|
100
|
+
s.mask = mask
|
99
101
|
if self.max_octets
|
100
102
|
buffer = "#{tags_text}"
|
101
103
|
formatted_communication.bytes do |byte|
|
data/spec/syslogger_spec.rb
CHANGED
@@ -102,6 +102,40 @@ describe "Syslogger" do
|
|
102
102
|
logger.write "yop"
|
103
103
|
end
|
104
104
|
|
105
|
+
it "should allow multiple instances to log at the same time" do
|
106
|
+
logger1 = Syslogger.new("my_app1", Syslog::LOG_PID, Syslog::LOG_USER)
|
107
|
+
logger2 = Syslogger.new("my_app2", Syslog::LOG_PID, Syslog::LOG_USER)
|
108
|
+
|
109
|
+
thread1 = Thread.new do
|
110
|
+
5000.times do |i|
|
111
|
+
logger1.write "logger1"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
thread2 = Thread.new do
|
116
|
+
5000.times do |i|
|
117
|
+
logger2.write "logger1"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
thread1.join
|
122
|
+
thread2.join
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should not fail under chaos" do
|
126
|
+
threads = []
|
127
|
+
(1..10).each do
|
128
|
+
threads << Thread.new do
|
129
|
+
(1..100).each do |index|
|
130
|
+
logger = Syslogger.new(Thread.current.inspect, Syslog::LOG_PID, Syslog::LOG_USER)
|
131
|
+
logger.write index
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
threads.each{|thread| thread.join }
|
137
|
+
end
|
138
|
+
|
105
139
|
describe "add" do
|
106
140
|
before do
|
107
141
|
@logger = Syslogger.new("my_app", Syslog::LOG_PID, Syslog::LOG_USER)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syslogger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Rohr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|