changeset 3505:cd43bbf56c33

logging: removed logging to ./moin.log from fallback config, better docs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 14 Apr 2008 18:47:57 +0200
parents 7ee94ad36708
children 6b6851d0a3c8
files MoinMoin/log.py MoinMoin/server/server_modpython.py docs/CHANGES wiki/config/logging/README 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, 56 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/log.py	Mon Apr 14 01:24:26 2008 +0200
+++ b/MoinMoin/log.py	Mon Apr 14 18:47:57 2008 +0200
@@ -10,9 +10,23 @@
     and load_config must be called afterwards, before any other moin
     module gets imported.
 
-    Usage
-    -----
-    Typically, do this at top of your module:
+    Usage (for wiki server admins)
+    ------------------------------
+    Typically, your server adaptor script (e.g. moin.cgi) will have this:
+
+    from MoinMoin import log
+    log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
+
+    You have to fix that path to use a logging configuration matching your
+    needs (we provide some examples in the path given there, it is relative to
+    the uncompressed moin distribution archive - if you use some moin package,
+    you maybe find it under /usr/share/moin/).
+    It is likely that you also have to edit the sample logging configurations
+    we provide (e.g. to fix the logfile location).
+
+    Usage (for developers)
+    ----------------------
+    If you write code for moin, do this at top of your module:
 
     from MoinMoin import log
     logging = log.getLogger(__name__)
@@ -31,10 +45,9 @@
 # that load_config() is either not called at all or with a non-working
 # logging configuration.
 # See http://www.python.org/doc/lib/logging-config-fileformat.html
-# We just use moin.log in current directory by default, if you want
-# anything else, override logging_conf in your server script's Config class.
+# We just use stderr output by default, if you want anything else,
+# you will have to configure logging.
 logging_defaults = {
-    'logdir': '.',
     'loglevel': 'INFO',
 }
 logging_config = """\
@@ -42,28 +55,22 @@
 keys=root
 
 [handlers]
-keys=logfile,stderr
+keys=stderr
 
 [formatters]
-keys=logfile
+keys=default
 
 [logger_root]
 level=%(loglevel)s
-handlers=logfile,stderr
-
-[handler_logfile]
-class=FileHandler
-level=NOTSET
-formatter=logfile
-args=('%(logdir)s/moin.log', 'at')
+handlers=stderr
 
 [handler_stderr]
 class=StreamHandler
 level=NOTSET
-formatter=logfile
+formatter=default
 args=(sys.stderr, )
 
-[formatter_logfile]
+[formatter_default]
 format=%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s
 datefmt=
 class=logging.Formatter
@@ -74,7 +81,6 @@
 configured = False
 fallback_config = False
 
-strip_MoinMoin = False
 
 def load_config(conf_fname):
     """ load logging config from conffile """
@@ -103,11 +109,8 @@
         - patch loglevel constants into logger object, so it can be used
           instead of the logging module
     """
-    global configured
     if not configured: # should not happen
         load_fallback_config()
-    if strip_MoinMoin and name.startswith('MoinMoin.'):
-        name = name[9:]
     logger = logging.getLogger(name)
     for levelnumber, levelname in logging._levelNames.items():
         if isinstance(levelnumber, int): # that list has also the reverse mapping...
--- a/MoinMoin/server/server_modpython.py	Mon Apr 14 01:24:26 2008 +0200
+++ b/MoinMoin/server/server_modpython.py	Mon Apr 14 18:47:57 2008 +0200
@@ -38,7 +38,6 @@
     """ Set up default server """
     properties = {}
 
-    # Set up log handler to log to apache log!
 
 def modpythonHandler(request, ConfigClass=ModpythonConfig):
     config = ConfigClass()
--- a/docs/CHANGES	Mon Apr 14 01:24:26 2008 +0200
+++ b/docs/CHANGES	Mon Apr 14 18:47:57 2008 +0200
@@ -69,7 +69,11 @@
       was changed to default False).
 
   New Features:
-    * new powerful and flexible logging, please see wiki/config/logging/.
+    * new powerful and flexible logging, please see wiki/config/logging/ -
+      HINT: you have to upgrade your server adaptor script (e.g. moin.cgi)
+      and load a logging configuration that fits your needs from there.
+      If you use some of our sample logging configs, make sure you have a
+      look INTO them to fix e.g. the path of the logfile it will use.
     * moin now logs the path from where it loaded its configuration(s)
     * cfg.trusted_auth_methods is a list of auth methods that put an
       authenticated user into the "Trusted" ACL group.
--- a/wiki/config/logging/README	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/config/logging/README	Mon Apr 14 18:47:57 2008 +0200
@@ -1,12 +1,17 @@
 In this directory is a collection of pre-made logging configuration files.
 
-You can use them like this:
+Typically, your server adaptor script (e.g. moin.cgi) will have this:
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/conffile')
+log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
-This is usually located somewhere at the begging of the server script you use,
-e.g. in moin.cgi, if you use cgi.
+You have to fix that path to use a logging configuration matching your
+needs (we provide some examples in the path given there, it is relative to
+the uncompressed moin distribution archive - if you use some moin package,
+you maybe find it under /usr/share/moin/).
+
+It is likely that you also have to edit the sample logging configurations
+we provide (e.g. to fix the logfile location).
 
 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
--- a/wiki/server/moin.cgi	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moin.cgi	Mon Apr 14 18:47:57 2008 +0200
@@ -3,7 +3,8 @@
 """
     MoinMoin - CGI Driver Script
 
-    @copyright: 2000-2005 by Juergen Hermann <jh@web.de>
+    @copyright: 2000-2005 by Juergen Hermann <jh@web.de>,
+                2008 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -27,7 +28,7 @@
 ## os.environ['MOIN_DEBUG'] = '1'
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/conffile') # XXX fix path
+log.load_config('wiki/config/logging/conffile') # XXX please fix this path!
 
 from MoinMoin.server.server_cgi import CgiConfig, run
 
--- a/wiki/server/moin.fcg	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moin.fcg	Mon Apr 14 18:47:57 2008 +0200
@@ -3,7 +3,7 @@
 """
     MoinMoin - FastCGI Driver Script
     
-    @copyright: 2007 MoinMoin:ThomasWaldmann
+    @copyright: 2008 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -25,7 +25,7 @@
 #os.environ['MOIN_DEBUG'] = '1'
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
 from MoinMoin.server.server_fastcgi import FastCgiConfig, run
 
--- a/wiki/server/moin.py	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moin.py	Mon Apr 14 18:47:57 2008 +0200
@@ -2,7 +2,8 @@
 """
     Start script for the standalone Wiki server.
 
-    @copyright: 2007 MoinMoin:ForrestVoight
+    @copyright: 2007 MoinMoin:ForrestVoight,
+                2008 MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -17,7 +18,7 @@
 os.chdir(moinpath)
 
 from MoinMoin import log
-log.load_config('wiki/config/logging/stderr') # XXX maybe fix path
+log.load_config('wiki/config/logging/stderr') # XXX please fix this path!
 
 from MoinMoin.script import MoinScript
 
--- a/wiki/server/moin.wsgi	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moin.wsgi	Mon Apr 14 18:47:57 2008 +0200
@@ -17,7 +17,7 @@
     # use the daemons we defined above to process requests!
     WSGIProcessGroup daemonname
 
-    @copyright: 2007 by MoinMoin:ThomasWaldmann
+    @copyright: 2008 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -35,14 +35,14 @@
 sys.path.insert(0, '/path/to/wikiconfig')
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
 from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp
 
 class Config(WsgiConfig):
     pass
 
-config = Config() # MUST create an instance to init logging!
+config = Config()
 
 application = moinmoinApp
 
--- a/wiki/server/moin_flup_wsgi.py	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moin_flup_wsgi.py	Mon Apr 14 18:47:57 2008 +0200
@@ -2,7 +2,7 @@
     MoinMoin - Moin as WSGI application with flup as fcgi gateway
 
     @copyright: 2005 by Anakim Border <akborder@gmail.com>,
-                2007 by MoinMoin:ThomasWaldmann
+                2008 by MoinMoin:ThomasWaldmann
     @license: GNU GPL, see COPYING for details.
 """
 
@@ -12,7 +12,7 @@
 import os
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
 # Set threads flag, so other code can use proper locking
 from MoinMoin import config
@@ -25,7 +25,7 @@
 class Config(WsgiConfig):
     pass
 
-config = Config() # MUST create an instance
+config = Config()
 
 if __name__ == '__main__':
     server = WSGIServer(moinmoinApp, bindAddress=unixSocketPath)
--- a/wiki/server/moinmodpy.py	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/moinmodpy.py	Mon Apr 14 18:47:57 2008 +0200
@@ -49,7 +49,7 @@
 ## os.environ['MOIN_DEBUG'] = '1'
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/conffile') # XXX fix path
+log.load_config('wiki/config/logging/conffile') # XXX please fix this path!
 
 # Simple way
 #from MoinMoin.server.server_modpython import modpythonHandler as handler
@@ -66,3 +66,4 @@
 
 def handler(request):
     return modpythonHandler(request, MyConfig)
+
--- a/wiki/server/mointwisted	Mon Apr 14 01:24:26 2008 +0200
+++ b/wiki/server/mointwisted	Mon Apr 14 18:47:57 2008 +0200
@@ -13,7 +13,7 @@
 import os
 
 from MoinMoin import log
-log.load_config('.../wiki/config/logging/logfile') # XXX fix path
+log.load_config('wiki/config/logging/logfile') # XXX please fix this path!
 
 from MoinMoin.server import daemon
 from mointwisted import Config
@@ -23,7 +23,7 @@
 
     def do_start(self):
         """ Override to use twistd daemonizer """
-        os.system('twistd --python mointwisted.py --pidfile %s' % self.pidFile)       
+        os.system('twistd --python mointwisted.py --pidfile %s' % self.pidFile)
 
 
 script = TwistedScript(Config.name, None)