syslog-sd 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -1
- data/VERSION +1 -1
- data/lib/syslog-sd/notifier.rb +3 -2
- data/syslog-sd.gemspec +2 -2
- data/test/test_notifier.rb +9 -0
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.2, 2010-05-18:
|
2
|
+
+ Allow to send timestamp as float if desired. It may improve server's parsing speed.
|
3
|
+
|
4
|
+
1.2.2, 2010-05-17:
|
2
5
|
* Minor metadata update. Moved to http://github.com/Graylog2/syslog-sd-rb
|
6
|
+
* Return actual message from SyslogSD::Notifier#notify.
|
3
7
|
|
4
8
|
1.2.0, 2010-05-17:
|
5
9
|
+ Initial version, based on master branch of `gelf` gem.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.3
|
data/lib/syslog-sd/notifier.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module SyslogSD
|
2
2
|
# syslog notifier.
|
3
3
|
class Notifier
|
4
|
-
attr_accessor :enabled, :collect_file_and_line
|
4
|
+
attr_accessor :enabled, :collect_file_and_line, :timestamp_as_float
|
5
5
|
attr_reader :level, :default_options, :level_mapping
|
6
6
|
|
7
7
|
# +host+ and +port+ are host/ip and port of syslog server.
|
@@ -12,6 +12,7 @@ module SyslogSD
|
|
12
12
|
@sd_id = "_@37797"
|
13
13
|
|
14
14
|
self.level = SyslogSD::DEBUG
|
15
|
+
self.timestamp_as_float = false
|
15
16
|
|
16
17
|
self.default_options = default_options
|
17
18
|
self.default_options['host'] ||= Socket.gethostname
|
@@ -184,7 +185,7 @@ module SyslogSD
|
|
184
185
|
|
185
186
|
prival = 128 + @hash.delete('level') # 128 = 16(local0) * 8
|
186
187
|
t = Time.now.utc
|
187
|
-
timestamp = t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec.to_s[0,3]}Z")
|
188
|
+
timestamp = timestamp_as_float ? t.to_f : t.strftime("%Y-%m-%dT%H:%M:%S.#{t.usec.to_s[0,3]}Z")
|
188
189
|
host = @hash.delete('host')
|
189
190
|
facility = @hash.delete('facility') || '-'
|
190
191
|
procid = @hash.delete('procid')
|
data/syslog-sd.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{syslog-sd}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Alexey Palazhchenko}, %q{Lennart Koopmann}]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-18}
|
13
13
|
s.description = %q{Super-Duper library to send syslog messages over UDP to logging server such as Graylog2. Supports Structured Data elements as defined by RFC 5424.}
|
14
14
|
s.email = %q{alexey.palazhchenko@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_notifier.rb
CHANGED
@@ -135,6 +135,15 @@ class TestNotifier < Test::Unit::TestCase
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
should "send timestamp as float if desired" do
|
139
|
+
@notifier.timestamp_as_float = true
|
140
|
+
hash = { 'short_message' => 'message', 'level' => SyslogSD::WARN, 'host' => 'host', 'facility' => 'facility', 'procid' => 123,
|
141
|
+
'msgid' => 'msgid', 'user_id' => 123 }
|
142
|
+
expected = '<132>1 1274011994.0 host facility 123 msgid [@sd_id user_id="123"] message'
|
143
|
+
@notifier.instance_variable_set('@hash', hash)
|
144
|
+
assert_equal expected, @notifier.__send__(:serialize_hash)
|
145
|
+
end
|
146
|
+
|
138
147
|
teardown do
|
139
148
|
Timecop.return
|
140
149
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syslog-sd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 3
|
10
|
+
version: 1.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexey Palazhchenko
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-05-
|
19
|
+
date: 2011-05-18 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: shoulda
|