Logging extended
This commit is contained in:
parent
3b8cae9ca4
commit
19929f069b
2 changed files with 20 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue