diff --git a/lib/logan/inc/main.rb b/lib/logan/inc/main.rb index dd82c01..6c12915 100644 --- a/lib/logan/inc/main.rb +++ b/lib/logan/inc/main.rb @@ -8,10 +8,15 @@ require 'logan/loglines' require 'logan/cache' module LogAn::Logging - def log lvl, *txt - $stderr.puts( ([Time.now, lvl]+txt).inspect) + class << self + def log lvl, *txt + $stderr.puts( ([Time.now, lvl]+txt).inspect) + end + alias method_missing log + end + def method_missing *paras + self.class.log *paras end - alias method_missing log end module LogAn::Inc diff --git a/lib/logan/inc/server.rb b/lib/logan/inc/server.rb index 4f03e3b..0440ae3 100644 --- a/lib/logan/inc/server.rb +++ b/lib/logan/inc/server.rb @@ -53,13 +53,18 @@ class LogAn::Inc::Select <::Select end class LogAn::Inc::Socket <::Select::Socket + def initialize *p + super( *p) + LogAn::Logging.info :connected, self + end + def event_read sock = @sock, event = :read begin @linebuf += sock.readpartial( @bufsize) rescue EOFError self.event_eof sock - rescue Errno::EPIPE => e - self.event_errno e, sock, event + rescue Errno::EPIPE + self.event_errno $!, sock, event rescue IOError self.event_ioerror sock, event rescue Errno::ECONNRESET => e @@ -73,6 +78,11 @@ class LogAn::Inc::Socket <::Select::Socket event_cmd @linebuf.remove( l) end end + + def close + LogAn::Logging.info :disconnect, self + super + end end class LogAn::Inc::Server < ::Select::Server