Commit f7b486c3 authored by Amos Latteier's avatar Amos Latteier

Changes to ZServer servers to use new log_info architecture. Plus a change to re-route medusa

logging to zLOG if available. This is sub-optimal, but not bad, and allows ZServer to
continue to not rely on any Zope packages except ZPublisher.
parent 50f9a519
......@@ -486,7 +486,7 @@ class zope_ftp_channel(ftp_channel):
self.respond ('230 Login successful.')
self.authorized = 1
self.anonymous = 1
self.log ('Successful login.')
self.log_info ('Successful login.')
else:
self.respond('421 User limit reached. Closing connection.')
self.close_when_done()
......@@ -516,7 +516,7 @@ class zope_ftp_channel(ftp_channel):
self.authorized = 1
if self.userid=='anonymous':
self.anonymous=1
self.log('Successful login.')
self.log_info('Successful login.')
self.respond('230 Login successful.')
else:
self.respond('530 Unauthorized.')
......@@ -616,7 +616,7 @@ class FTPServer(ftp_server):
def handle_accept (self):
conn, addr = self.accept()
self.total_sessions.increment()
print 'Incoming connection from %s:%d' % (addr[0], addr[1])
self.log_info('Incoming connection from %s:%d' % (addr[0], addr[1]))
self.ftp_channel_class (self, conn, addr, self.module)
def readable(self):
......
......@@ -122,6 +122,10 @@ from medusa.default_handler import split_path, unquote, get_header
from ZServer import CONNECTION_LIMIT, ZOPE_VERSION, ZSERVER_VERSION
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
register_subsystem('ZServer HTTPServer')
CONTENT_LENGTH = regex.compile('Content-Length: \([0-9]+\)',regex.casefold)
CONNECTION = regex.compile ('Connection: \(.*\)', regex.casefold)
......@@ -194,9 +198,6 @@ class zhttp_handler:
self.continue_request(sin,request)
def get_environment(self,request):
# XXX add env overriding
[path, params, query, fragment] = split_path(request.uri)
while path and path[0] == '/':
path = path[1:]
......
......@@ -287,7 +287,7 @@ class PCGIServer(asyncore.dispatcher):
f.write(str(os.getpid()))
f.close()
except IOError:
self.log("Error, cannot write PID file.")
self.log_info("Cannot write PID file.", 'error')
# setup sockets
if self.port:
......@@ -335,7 +335,7 @@ class PCGIServer(asyncore.dispatcher):
try:
conn, addr = self.accept()
except socket.error:
sys.stderr.write('warning: server accept() threw an exception\n')
self.log_info('Server accept() threw an exception', 'warning')
return
self.channel_class(self, conn, addr)
......
......@@ -86,6 +86,7 @@
from medusa import max_sockets
CONNECTION_LIMIT=max_sockets.max_select_sockets()
ZSERVER_VERSION='1.1b1'
try:
import App.version_txt
......@@ -93,10 +94,30 @@ try:
except:
ZOPE_VERSION='experimental'
# Try to poke zLOG default logging into asyncore
# XXX We should probably should do a better job of this,
# however that would mean that ZServer required zLOG.
try:
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
register_subsystem('ZServer')
severity={'info':INFO, 'warning':WARNING, 'error': ERROR}
def log_info(self, message, type='info'):
if message[:14]=='adding channel' or \
message[:15]=='closing channel':
LOG('ZServer', BLATHER, message)
else:
LOG('ZServer', severity[type], message)
from medusa import asyncore
asyncore.dispatcher.log_info=log_info
except:
pass
from medusa import resolver, logger, asyncore
from HTTPServer import zhttp_server, zhttp_handler
from PCGIServer import PCGIServer
from FTPServer import FTPServer
from PubCore import setNumberOfThreads
from medusa.monitor import secure_monitor_server
......@@ -486,7 +486,7 @@ class zope_ftp_channel(ftp_channel):
self.respond ('230 Login successful.')
self.authorized = 1
self.anonymous = 1
self.log ('Successful login.')
self.log_info ('Successful login.')
else:
self.respond('421 User limit reached. Closing connection.')
self.close_when_done()
......@@ -516,7 +516,7 @@ class zope_ftp_channel(ftp_channel):
self.authorized = 1
if self.userid=='anonymous':
self.anonymous=1
self.log('Successful login.')
self.log_info('Successful login.')
self.respond('230 Login successful.')
else:
self.respond('530 Unauthorized.')
......@@ -616,7 +616,7 @@ class FTPServer(ftp_server):
def handle_accept (self):
conn, addr = self.accept()
self.total_sessions.increment()
print 'Incoming connection from %s:%d' % (addr[0], addr[1])
self.log_info('Incoming connection from %s:%d' % (addr[0], addr[1]))
self.ftp_channel_class (self, conn, addr, self.module)
def readable(self):
......
......@@ -122,6 +122,10 @@ from medusa.default_handler import split_path, unquote, get_header
from ZServer import CONNECTION_LIMIT, ZOPE_VERSION, ZSERVER_VERSION
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
register_subsystem('ZServer HTTPServer')
CONTENT_LENGTH = regex.compile('Content-Length: \([0-9]+\)',regex.casefold)
CONNECTION = regex.compile ('Connection: \(.*\)', regex.casefold)
......@@ -194,9 +198,6 @@ class zhttp_handler:
self.continue_request(sin,request)
def get_environment(self,request):
# XXX add env overriding
[path, params, query, fragment] = split_path(request.uri)
while path and path[0] == '/':
path = path[1:]
......
......@@ -287,7 +287,7 @@ class PCGIServer(asyncore.dispatcher):
f.write(str(os.getpid()))
f.close()
except IOError:
self.log("Error, cannot write PID file.")
self.log_info("Cannot write PID file.", 'error')
# setup sockets
if self.port:
......@@ -335,7 +335,7 @@ class PCGIServer(asyncore.dispatcher):
try:
conn, addr = self.accept()
except socket.error:
sys.stderr.write('warning: server accept() threw an exception\n')
self.log_info('Server accept() threw an exception', 'warning')
return
self.channel_class(self, conn, addr)
......
......@@ -86,6 +86,7 @@
from medusa import max_sockets
CONNECTION_LIMIT=max_sockets.max_select_sockets()
ZSERVER_VERSION='1.1b1'
try:
import App.version_txt
......@@ -93,10 +94,30 @@ try:
except:
ZOPE_VERSION='experimental'
# Try to poke zLOG default logging into asyncore
# XXX We should probably should do a better job of this,
# however that would mean that ZServer required zLOG.
try:
from zLOG import LOG, register_subsystem, BLATHER, INFO, WARNING, ERROR
register_subsystem('ZServer')
severity={'info':INFO, 'warning':WARNING, 'error': ERROR}
def log_info(self, message, type='info'):
if message[:14]=='adding channel' or \
message[:15]=='closing channel':
LOG('ZServer', BLATHER, message)
else:
LOG('ZServer', severity[type], message)
from medusa import asyncore
asyncore.dispatcher.log_info=log_info
except:
pass
from medusa import resolver, logger, asyncore
from HTTPServer import zhttp_server, zhttp_handler
from PCGIServer import PCGIServer
from FTPServer import FTPServer
from PubCore import setNumberOfThreads
from medusa.monitor import secure_monitor_server
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment