Logging extended
This commit is contained in:
parent
3b8cae9ca4
commit
19929f069b
|
@ -8,10 +8,15 @@ require 'logan/loglines'
|
||||||
require 'logan/cache'
|
require 'logan/cache'
|
||||||
|
|
||||||
module LogAn::Logging
|
module LogAn::Logging
|
||||||
def log lvl, *txt
|
class << self
|
||||||
$stderr.puts( ([Time.now, lvl]+txt).inspect)
|
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
|
end
|
||||||
alias method_missing log
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module LogAn::Inc
|
module LogAn::Inc
|
||||||
|
|
|
@ -53,13 +53,18 @@ class LogAn::Inc::Select <::Select
|
||||||
end
|
end
|
||||||
|
|
||||||
class LogAn::Inc::Socket <::Select::Socket
|
class LogAn::Inc::Socket <::Select::Socket
|
||||||
|
def initialize *p
|
||||||
|
super( *p)
|
||||||
|
LogAn::Logging.info :connected, self
|
||||||
|
end
|
||||||
|
|
||||||
def event_read sock = @sock, event = :read
|
def event_read sock = @sock, event = :read
|
||||||
begin
|
begin
|
||||||
@linebuf += sock.readpartial( @bufsize)
|
@linebuf += sock.readpartial( @bufsize)
|
||||||
rescue EOFError
|
rescue EOFError
|
||||||
self.event_eof sock
|
self.event_eof sock
|
||||||
rescue Errno::EPIPE => e
|
rescue Errno::EPIPE
|
||||||
self.event_errno e, sock, event
|
self.event_errno $!, sock, event
|
||||||
rescue IOError
|
rescue IOError
|
||||||
self.event_ioerror sock, event
|
self.event_ioerror sock, event
|
||||||
rescue Errno::ECONNRESET => e
|
rescue Errno::ECONNRESET => e
|
||||||
|
@ -73,6 +78,11 @@ class LogAn::Inc::Socket <::Select::Socket
|
||||||
event_cmd @linebuf.remove( l)
|
event_cmd @linebuf.remove( l)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def close
|
||||||
|
LogAn::Logging.info :disconnect, self
|
||||||
|
super
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class LogAn::Inc::Server < ::Select::Server
|
class LogAn::Inc::Server < ::Select::Server
|
||||||
|
|
Loading…
Reference in a new issue