Mercurial > moin > 1.9
changeset 3107:c6e39279f83b
refactor logging usage
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Sat, 23 Feb 2008 22:59:30 +0100 |
parents | af3dd2bc85cc |
children | 2572688e031a |
files | MoinMoin/config/multiconfig.py MoinMoin/conftest.py MoinMoin/events/__init__.py MoinMoin/events/wikidictsrescan.py MoinMoin/formatter/__init__.py MoinMoin/i18n/__init__.py MoinMoin/logfile/__init__.py MoinMoin/logfile/editlog.py MoinMoin/parser/text_moin_wiki.py MoinMoin/request/__init__.py MoinMoin/security/antispam.py MoinMoin/security/textcha.py MoinMoin/server/__init__.py MoinMoin/server/server_fastcgi.py MoinMoin/server/server_standalone.py MoinMoin/server/server_wsgi.py MoinMoin/support/thfcgi.py MoinMoin/util/moinoid.py MoinMoin/wikiutil.py wiki/server/moin.fcg wiki/server/moin.wsgi wiki/server/moin_flup_wsgi.py |
diffstat | 22 files changed, 105 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/config/multiconfig.py Sat Feb 23 22:59:30 2008 +0100 @@ -11,7 +11,12 @@ import os import sys import time -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import config, error, util, wikiutil import MoinMoin.auth as authmodule
--- a/MoinMoin/conftest.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/conftest.py Sat Feb 23 22:59:30 2008 +0100 @@ -22,7 +22,7 @@ # here you can configure logging used while running the tests, # see http://www.python.org/doc/lib/logging-config-fileformat.html logging_defaults = { - 'loglevel': 'DEBUG', + 'loglevel': 'INFO', } logging_config = """\ [loggers]
--- a/MoinMoin/events/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/events/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -9,7 +9,11 @@ @license: GNU GPL, see COPYING for details. """ -import logging +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import wikiutil from MoinMoin.util import pysupport @@ -18,11 +22,6 @@ # Create a list of extension actions from the package directory modules = pysupport.getPackageModules(__file__) -# A module-wide Logger, don't use it from outside -logger = logging.getLogger("events") -logger.setLevel(logging.DEBUG) -logger.addHandler(logging.StreamHandler()) - # Dummy pseudo-getText function used in event descriptions, # so that they get into .po files _ = lambda x: x
--- a/MoinMoin/events/wikidictsrescan.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/events/wikidictsrescan.py Sat Feb 23 22:59:30 2008 +0100 @@ -7,7 +7,12 @@ @copyright: 2007 by MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import events as ev from MoinMoin import wikidicts @@ -35,3 +40,4 @@ gd = wikidicts.GroupDict(request) gd.scan_dicts() logging.debug("groupsdicts changed: scan_dicts finished") +
--- a/MoinMoin/formatter/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/formatter/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -8,7 +8,12 @@ @license: GNU GPL, see COPYING for details. """ import re -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin.util import pysupport from MoinMoin import wikiutil @@ -337,7 +342,7 @@ args = None if lines: args = self._get_bang_args(lines[0]) - #logging.debug("formatter.parser: parser args %r" % args) + logging.debug("formatter.parser: parser args %r" % args) if args is not None: lines = lines[1:] if lines and not lines[0]:
--- a/MoinMoin/i18n/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/i18n/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -25,9 +25,14 @@ """ import os, gettext, glob -import logging from StringIO import StringIO +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) + from MoinMoin import caching # This is a global for a reason: in persistent environments all languages in
--- a/MoinMoin/logfile/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/logfile/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -7,7 +7,12 @@ @copyright: 2005-2007 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) import os, codecs, errno from MoinMoin import config, wikiutil
--- a/MoinMoin/logfile/editlog.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/logfile/editlog.py Sat Feb 23 22:59:30 2008 +0100 @@ -15,7 +15,11 @@ @license: GNU GPL, see COPYING for details. """ -import logging +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin.logfile import LogFile from MoinMoin import wikiutil, user, config
--- a/MoinMoin/parser/text_moin_wiki.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/parser/text_moin_wiki.py Sat Feb 23 22:59:30 2008 +0100 @@ -9,7 +9,12 @@ """ import re -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import config, wikiutil, macro from MoinMoin.Page import Page
--- a/MoinMoin/request/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/request/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -14,8 +14,11 @@ proxies_trusted = [] # trust noone! #proxies_trusted = ['127.0.0.1', ] # can be a list of multiple IPs -import logging -proxy_loglevel = logging.INFO # logging.NOTSET (never), .DEBUG, .INFO +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) def find_remote_addr(addrs): """ Find the last remote IP address before it hits our reverse proxies. @@ -33,7 +36,7 @@ TODO: add wikiconfig configurability for proxies_trusted TODO: later, make it possible to put multipe remote IP addrs into edit-log """ - logging.log(proxy_loglevel, "request.find_remote_addr: addrs == %r" % addrs) + logging.debug("request.find_remote_addr: addrs == %r" % addrs) if proxies_trusted: result = [addr for addr in addrs if addr not in proxies_trusted] if result:
--- a/MoinMoin/security/antispam.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/security/antispam.py Sat Feb 23 22:59:30 2008 +0100 @@ -17,7 +17,11 @@ except NameError: from sets import ImmutableSet as frozenset -import logging +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin.security import Permissions from MoinMoin import caching, wikiutil
--- a/MoinMoin/security/textcha.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/security/textcha.py Sat Feb 23 22:59:30 2008 +0100 @@ -23,7 +23,12 @@ import re import random -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import wikiutil
--- a/MoinMoin/server/__init__.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/server/__init__.py Sat Feb 23 22:59:30 2008 +0100 @@ -20,13 +20,19 @@ fileConfig(StringIO(conf), defaults) def getLogger(name): + # do we want to strip MoinMoin. from the name? + #if 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... setattr(logger, levelname, levelnumber) return logger -logging = getLogger('') +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) def switchUID(uid, gid): """ Switch identity to safe user and group
--- a/MoinMoin/server/server_fastcgi.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/server/server_fastcgi.py Sat Feb 23 22:59:30 2008 +0100 @@ -22,8 +22,6 @@ @license: GNU GPL, see COPYING for details. """ -import logging - from MoinMoin.server import Config from MoinMoin.request import request_fcgi from MoinMoin.support import thfcgi
--- a/MoinMoin/server/server_standalone.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/server/server_standalone.py Sat Feb 23 22:59:30 2008 +0100 @@ -34,9 +34,15 @@ @license: GNU GPL, see COPYING for details. """ -import os, sys, time, socket, errno, shutil, logging +import os, sys, time, socket, errno, shutil import BaseHTTPServer, SimpleHTTPServer, SocketServer +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) + from MoinMoin import version, wikiutil from MoinMoin.server import Config, switchUID from MoinMoin.request import request_standalone
--- a/MoinMoin/server/server_wsgi.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/server/server_wsgi.py Sat Feb 23 22:59:30 2008 +0100 @@ -3,7 +3,6 @@ Minimal code for using this: - import logging from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp class Config(WsgiConfig):
--- a/MoinMoin/support/thfcgi.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/support/thfcgi.py Sat Feb 23 22:59:30 2008 +0100 @@ -35,8 +35,11 @@ # TODO: Compare compare the number of bytes received on FCGI_STDIN with # CONTENT_LENGTH and abort the update if the two numbers are not equal. -import logging -LOGLEVEL = logging.DEBUG # logging.NOTSET to completely switch it off +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) import os import sys @@ -101,7 +104,7 @@ def log(s): - logging.log(LOGLEVEL, 'thfcgi: %s' % s) + logging.debug(s) class SocketErrorOnWrite: """Is raised if a write fails in the socket code."""
--- a/MoinMoin/util/moinoid.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/util/moinoid.py Sat Feb 23 22:59:30 2008 +0100 @@ -5,15 +5,22 @@ @license: GNU GPL, see COPYING for details. """ -from MoinMoin import caching +from sha import sha +from random import randint +import time + from openid import oidutil from openid.store.interface import OpenIDStore from openid.association import Association from openid.store import nonce -import logging -from sha import sha -from random import randint -import time + +from MoinMoin import caching + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) # redirect openid logging to moin log def log(msg, level=0):
--- a/MoinMoin/wikiutil.py Sat Feb 23 21:45:02 2008 +0100 +++ b/MoinMoin/wikiutil.py Sat Feb 23 22:59:30 2008 +0100 @@ -16,7 +16,12 @@ import re import time import urllib -import logging + +from MoinMoin.server import getLogger +logging = getLogger(__name__) + +# use this to temporarily and selectively enable debug logging for this module +#logging.setLevel(logging.DEBUG) from MoinMoin import config from MoinMoin.util import pysupport, lock
--- a/wiki/server/moin.fcg Sat Feb 23 21:45:02 2008 +0100 +++ b/wiki/server/moin.fcg Sat Feb 23 22:59:30 2008 +0100 @@ -7,7 +7,7 @@ @license: GNU GPL, see COPYING for details. """ -import sys, logging +import sys # Path to MoinMoin package, needed if you installed with --prefix=PREFIX # or if you did not use setup.py.
--- a/wiki/server/moin.wsgi Sat Feb 23 21:45:02 2008 +0100 +++ b/wiki/server/moin.wsgi Sat Feb 23 22:59:30 2008 +0100 @@ -34,8 +34,6 @@ # YOU NEED TO CHANGE THIS TO MATCH YOUR SETUP. sys.path.insert(0, '/path/to/wikiconfig') -import logging - from MoinMoin.server.server_wsgi import WsgiConfig, moinmoinApp class Config(WsgiConfig):