changeset 3111:79f850129782

logging: fix server scripts to load logging config, fix logging configs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 25 Feb 2008 14:01:08 +0100
parents a48929a5036c
children dc182f4936b1
files moin.py wiki/config/logging/README wiki/config/logging/logfile wiki/config/logging/stderr wiki/server/moin.cgi wiki/server/moin.fcg wiki/server/moin.py wiki/server/moin.wsgi wiki/server/moin_flup_wsgi.py wiki/server/moinmodpy.py wiki/server/mointwisted
diffstat 11 files changed, 65 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/moin.py	Mon Feb 25 03:41:39 2008 +0100
+++ b/moin.py	Mon Feb 25 14:01:08 2008 +0100
@@ -6,10 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import sys
-import os
-
-from MoinMoin.script import MoinScript
+import os, sys
 
 # Path to MoinMoin package, needed if you installed with --prefix=PREFIX
 # or if you did not use setup.py.
@@ -19,6 +16,11 @@
 sys.path.insert(0, moinpath)
 os.chdir(moinpath)
 
+from MoinMoin import log
+log.load_config('wiki/config/logging/stderr') # XXX maybe fix path
+
+from MoinMoin.script import MoinScript
+
 if __name__ == '__main__':
     sys.argv = ["moin.py", "server", "standalone"]
     MoinScript().run()
--- a/wiki/config/logging/README	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/config/logging/README	Mon Feb 25 14:01:08 2008 +0100
@@ -1,6 +1,23 @@
-In this directory is a collection of pre-made snippets you can put into your
-wiki config to configure logging. You may have to edit them at some places,
-please read the comments in the snippet.
+In this directory is a collection of pre-made logging configuration files.
+
+You can use them like this:
+
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/conffile')
+
+This is usually located somewhere at the begging of the server script you use,
+e.g. in moin.cgi, if you use cgi.
+
+If you don't configure logging using those lines, moin will use some built-in
+logging configuration (which might be correct for some cases, but incorrect
+for some other cases, so be careful!).
+
+CGI
+---
+You need to edit the moin.cgi that your webserver runs.
+
+CGI / Apache: use the stderr configuration, stuff will go to apache error.log
+CGI / IIS: use the logfile configuration and edit the logfile path
 
 You can make very flexible and powerful logging configurations using this
 mechanism, for more details see:
--- a/wiki/config/logging/logfile	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/config/logging/logfile	Mon Feb 25 14:01:08 2008 +0100
@@ -1,11 +1,11 @@
-    logging_defaults = {
-        # Directory where logfiles will be created.
-        # Make sure the running moin process has create/write rights there.
-        'logdir': '/path/to/logdir',
-        # Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
-        'loglevel': 'INFO',
-    }
-    logging_config = """\
+[DEFAULT]
+# Logfile to create.
+# Make sure the running moin process has create/write rights there.
+logfile=/tmp/moin.log
+
+# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
+loglevel=INFO
+
 [loggers]
 keys=root
 
@@ -16,19 +16,17 @@
 keys=logfile
 
 [logger_root]
-level=NOTSET
+level=%(loglevel)s
 handlers=logfile
 
 [handler_logfile]
 class=FileHandler
 formatter=logfile
 level=%(loglevel)s
-args=('%(logdir)s/moin.log', 'at')
+args=('%(logfile)s', 'at')
 
 [formatter_logfile]
 format=%(asctime)s %(name)s %(levelname)s %(message)s
 datefmt=
 class=logging.Formatter
-"""
 
-
--- a/wiki/config/logging/stderr	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/config/logging/stderr	Mon Feb 25 14:01:08 2008 +0100
@@ -1,8 +1,7 @@
-    logging_defaults = {
-        # Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
-        'loglevel': 'INFO',
-    }
-    logging_config = """\
+[DEFAULT]
+# Default loglevel, to adjust verbosity: DEBUG, INFO, WARNING, ERROR, CRITICAL
+loglevel=INFO
+
 [loggers]
 keys=root
 
@@ -13,7 +12,7 @@
 keys=screen
 
 [logger_root]
-level=NOTSET
+level=%(loglevel)s
 handlers=stderr
 
 [handler_stderr]
@@ -26,6 +25,4 @@
 format=%(asctime)s %(name)s %(levelname)s %(message)s
 datefmt=
 class=logging.Formatter
-"""
 
-
--- a/wiki/server/moin.cgi	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moin.cgi	Mon Feb 25 14:01:08 2008 +0100
@@ -26,6 +26,9 @@
 ## import os
 ## os.environ['MOIN_DEBUG'] = '1'
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/conffile') # XXX fix path
+
 from MoinMoin.server.server_cgi import CgiConfig, run
 
 class Config(CgiConfig):
--- a/wiki/server/moin.fcg	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moin.fcg	Mon Feb 25 14:01:08 2008 +0100
@@ -24,6 +24,9 @@
 #import os
 #os.environ['MOIN_DEBUG'] = '1'
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+
 from MoinMoin.server.server_fastcgi import FastCgiConfig, run
 
 class Config(FastCgiConfig):
--- a/wiki/server/moin.py	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moin.py	Mon Feb 25 14:01:08 2008 +0100
@@ -6,10 +6,7 @@
     @license: GNU GPL, see COPYING for details.
 """
 
-import sys
-import os
-
-from MoinMoin.script import MoinScript
+import os, sys
 
 # Path to MoinMoin package, needed if you installed with --prefix=PREFIX
 # or if you did not use setup.py.
@@ -19,6 +16,11 @@
 sys.path.insert(0, moinpath)
 os.chdir(moinpath)
 
+from MoinMoin import log
+log.load_config('wiki/config/logging/stderr') # XXX maybe fix path
+
+from MoinMoin.script import MoinScript
+
 if __name__ == '__main__':
     sys.argv = ["moin.py", "server", "standalone"]
     MoinScript().run()
--- a/wiki/server/moin.wsgi	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moin.wsgi	Mon Feb 25 14:01:08 2008 +0100
@@ -34,6 +34,9 @@
 # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP.
 sys.path.insert(0, '/path/to/wikiconfig')
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+
 from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
 
 class Config(WsgiConfig):
--- a/wiki/server/moin_flup_wsgi.py	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moin_flup_wsgi.py	Mon Feb 25 14:01:08 2008 +0100
@@ -11,6 +11,9 @@
 
 import os
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+
 # Set threads flag, so other code can use proper locking
 from MoinMoin import config
 config.use_threads = use_threads
--- a/wiki/server/moinmodpy.py	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/moinmodpy.py	Mon Feb 25 14:01:08 2008 +0100
@@ -48,6 +48,9 @@
 ## import os
 ## os.environ['MOIN_DEBUG'] = '1'
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/conffile') # XXX fix path
+
 # Simple way
 #from MoinMoin.server.server_modpython import modpythonHandler as handler
 
--- a/wiki/server/mointwisted	Mon Feb 25 03:41:39 2008 +0100
+++ b/wiki/server/mointwisted	Mon Feb 25 14:01:08 2008 +0100
@@ -12,6 +12,9 @@
 
 import os
 
+from MoinMoin import log
+log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+
 from MoinMoin.server import daemon
 from mointwisted import Config