Browse files

Fixing a small bug in a pretty hackish way. Will clean up a bit more …

…later this weekend.
  • Loading branch information...
1 parent 9f7c0de commit 6841c2d536ccc46ffdfe75d55fefa35eac9c48ff @melito melito committed Jul 3, 2009
Showing with 9 additions and 6 deletions.
  1. +3 −0 README
  2. +1 −1 em-syslog.gemspec
  3. +3 −4 lib/em/syslog.rb
  4. +2 −1 test.rb
View
3 README
@@ -43,3 +43,6 @@ TODO:
Add support for TLS (syslog-ng)
Clean up API
Just improve everything.
+
+FIXES:
+ Was creating a new datagram socket everytime a packet was sent out. Only use one now.
View
2 em-syslog.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "em-syslog"
- s.version = "0.0.1"
+ s.version = "0.0.2"
s.date = "2009-06-30"
s.authors = ["Mel Gray"]
s.email = "melgray@gmail.com"
View
7 lib/em/syslog.rb
@@ -34,9 +34,7 @@ def log(severity, message, time = nil)
def send_msg(data)
EM.next_tick{
- EM.open_datagram_socket('0.0.0.0', 0) {|c|
- c.send_datagram(data, EM.syslog_server, EM.syslog_port)
- }
+ EM.syslog_sd.send_datagram(data, EM.syslog_server, EM.syslog_port)
}
end
private :send_msg
@@ -48,9 +46,10 @@ def send_msg(data)
# Class methods for EM
class << self
- attr_reader :syslog_server, :syslog_port
+ attr_reader :syslog_server, :syslog_port, :syslog_sd
def syslog_setup(server, port=514)
@syslog_server, @syslog_port = server, port
+ @syslog_sd = EM.open_datagram_socket('0.0.0.0', 0) # FIXME: Dumb quick fix.
end
# THIEVERY: http://github.com/kpumuk/ruby_syslog
View
3 test.rb
@@ -14,9 +14,10 @@
# p data
# end
#end
+
+ EM.syslog_setup(SYSLOG_SERVER, SYSLOG_PORT)
EM.add_periodic_timer(1) {
- EM.syslog_setup(SYSLOG_SERVER, SYSLOG_PORT)
EM.emergency('system is unusable')
EM.alert('action must be taken immediately')

0 comments on commit 6841c2d

Please sign in to comment.