Mercurial > moin > 1.9
changeset 3015:8d691fbdc929
WSGI: initialize logging (untested) (port from 1.6)
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sun, 06 Jan 2008 20:06:00 +0100 |
parents | dc970f2d146c |
children | 5b17fc649925 |
files | MoinMoin/server/server_wsgi.py wiki/server/moin.wsgi wiki/server/moin_flup_wsgi.py |
diffstat | 3 files changed, 44 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/server/server_wsgi.py Sun Jan 06 20:00:40 2008 +0100 +++ b/MoinMoin/server/server_wsgi.py Sun Jan 06 20:06:00 2008 +0100 @@ -1,12 +1,31 @@ """ MoinMoin - WSGI application - @copyright: 2005 Anakim Border <akborder@gmail.com> + Minimal code for using this: + + import logging + from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp + + class Config(WsgiConfig): + logPath = 'moin.log' # define your log file here + #loglevel_file = logging.INFO # if you do not like the default + + config = Config() # you MUST create an instance to initialize logging! + # use moinmoinApp here with your WSGI server / gateway + + @copyright: 2005 Anakim Border <akborder@gmail.com>, + 2007 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ +from MoinMoin.server import Config from MoinMoin.request import request_wsgi +class WsgiConfig(Config): + """ WSGI default config """ + loglevel_stderr = None # we do not want to write to stderr! + + def moinmoinApp(environ, start_response): request = request_wsgi.Request(environ) request.run()
--- a/wiki/server/moin.wsgi Sun Jan 06 20:00:40 2008 +0100 +++ b/wiki/server/moin.wsgi Sun Jan 06 20:06:00 2008 +0100 @@ -21,7 +21,6 @@ @license: GNU GPL, see COPYING for details. """ -# System path configuration import sys # Path to MoinMoin package, needed if you installed with --prefix=PREFIX @@ -35,5 +34,15 @@ # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP. sys.path.insert(0, '/path/to/wikiconfig') -from MoinMoin.server.server_wsgi import moinmoinApp as application +import logging + +from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp +class Config(WsgiConfig): + logPath = 'moin.log' # adapt this to your needs! + #loglevel_file = logging.INFO # adapt this to your needs! + +config = Config() # MUST create an instance to init logging! + +application = moinmoinApp +
--- a/wiki/server/moin_flup_wsgi.py Sun Jan 06 20:00:40 2008 +0100 +++ b/wiki/server/moin_flup_wsgi.py Sun Jan 06 20:06:00 2008 +0100 @@ -1,21 +1,30 @@ """ - MoinMoin - WSGI application + MoinMoin - Moin as WSGI application with flup as fcgi gateway - @copyright: 2005 by Anakim Border <akborder@gmail.com> + @copyright: 2005 by Anakim Border <akborder@gmail.com>, + 2007 by MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ use_threads = True unixSocketPath = '/tmp/moin.sock' +import os +import logging + # Set threads flag, so other code can use proper locking from MoinMoin import config config.use_threads = use_threads del config from flup.server.fcgi import WSGIServer -from MoinMoin.server.server_wsgi import moinmoinApp -import os +from MoinMoin.server.server_wsgi import moinmoinApp, WsgiConfig + +class Config(WsgiConfig): + logPath = 'moin.log' # adapt to your needs! + #loglevel_file = logging.INFO # adapt to your needs! + +config = Config() # MUST create an instance to init logging if __name__ == '__main__': server = WSGIServer(moinmoinApp, bindAddress=unixSocketPath)