[Zope-Checkins]
SVN: Zope/branches/2.9/lib/python/OFS/Application.py
Move to python logging module.
Chris Withers
chris at simplistix.co.uk
Sun Mar 12 09:20:54 EST 2006
Log message for revision 65919:
Move to python logging module.
Changed:
U Zope/branches/2.9/lib/python/OFS/Application.py
-=-
Modified: Zope/branches/2.9/lib/python/OFS/Application.py
===================================================================
--- Zope/branches/2.9/lib/python/OFS/Application.py 2006-03-12 10:56:46 UTC (rev 65918)
+++ Zope/branches/2.9/lib/python/OFS/Application.py 2006-03-12 14:20:53 UTC (rev 65919)
@@ -21,6 +21,7 @@
from warnings import warn
import Globals, Products, App.Product, App.ProductRegistry
+import logging
import transaction
from AccessControl.User import UserFolder
from Acquisition import aq_base
@@ -32,7 +33,6 @@
from HelpSys.HelpSys import HelpSys
from webdav.NullResource import NullResource
from zExceptions import Redirect as RedirectException, Forbidden
-from zLOG import LOG, ERROR, WARNING, INFO
from zope.interface import implements
import Folder
@@ -42,6 +42,7 @@
from interfaces import IApplication
from misc_ import Misc_
+logger = logging.getLogger('Zope')
class Application(Globals.ApplicationDefaultPermissions,
ZDOM.Root, Folder.Folder,
@@ -231,9 +232,7 @@
ob._register()
result=1
if not rebuild:
- LOG('Zope', INFO,
- 'Registered ZClass: %s' % ob.id
- )
+ logger.info('Registered ZClass: %s',ob.id)
# Include subobjects.
if hasattr(base, 'objectItems'):
m = list(ob.objectItems())
@@ -246,9 +245,9 @@
m = list(ps.methods.objectItems())
items.extend(m)
except:
- LOG('Zope', WARNING,
- 'Broken objects exist in product %s.' % product.id,
- error=sys.exc_info())
+ logger.warning('Broken objects exist in product %s.',
+ product.id,
+ exc_info=True)
return result
@@ -260,11 +259,11 @@
try:
keys=list(self._p_jar.root()['ZGlobals'].keys())
except:
- LOG('Zope', ERROR,
+ logger.error(
'A problem was found when checking the global product '\
'registry. This is probably due to a Product being '\
'uninstalled or renamed. The traceback follows.',
- error=sys.exc_info())
+ exc_info=True)
return 1
return 0
@@ -366,7 +365,7 @@
# tf is a MountPoint object. This means that the temp_folder
# couldn't be mounted properly (the meta_type would have been
# the meta type of the container class otherwise). The
- # MountPoint object writes a message to zLOG so we don't
+ # MountPoint object writes a message to the log so we don't
# need to.
return
@@ -379,10 +378,11 @@
mount_paths = [ x[0] for x in dbtab_config.listMountPaths() ]
if not '/temp_folder' in mount_paths:
# we won't be able to create the mount point properly
- LOG('Zope Default Object Creation', ERROR,
- ('Could not initialze a Temporary Folder because '
- 'a database was not configured to be mounted at '
- 'the /temp_folder mount point'))
+ logger.error((
+ 'Zope Default Object Creation: '
+ 'Could not initialze a Temporary Folder because '
+ 'a database was not configured to be mounted at '
+ 'the /temp_folder mount point'))
return
try:
manage_addMounts(app, ('/temp_folder',))
@@ -390,10 +390,11 @@
self.commit('Added temp_folder')
tf = app.temp_folder
except:
- LOG('Zope Default Object Creation', ERROR,
- ('Could not add a /temp_folder mount point due to an '
+ logger.error((
+ 'Zope Default Object Creation: '
+ 'Could not add a /temp_folder mount point due to an '
'error.'),
- error=sys.exc_info())
+ exc_info=True)
return
# Ensure that there is a transient object container in the temp folder
@@ -416,15 +417,15 @@
default_period_secs)
if addnotify and app.unrestrictedTraverse(addnotify, None) is None:
- LOG('Zope Default Object Creation', WARNING,
- ('failed to use nonexistent "%s" script as '
- 'session-add-notify-script-path' % addnotify))
+ logger.warning(('Zope Default Object Creation: '
+ 'failed to use nonexistent "%s" script as '
+ 'session-add-notify-script-path'),addnotify)
addnotify=None
if delnotify and app.unrestrictedTraverse(delnotify, None) is None:
- LOG('Zope Default Object Creation', WARNING,
- ('failed to use nonexistent "%s" script as '
- 'session-delete-notify-script-path' % delnotify))
+ logger.warning(('Zope Default Object Creation: '
+ 'failed to use nonexistent "%s" script as '
+ 'session-delete-notify-script-path'),delnotify)
delnotify=None
toc = TransientObjectContainer(
@@ -567,18 +568,16 @@
bad_things=0
try:
if app.checkGlobalRegistry():
- LOG('Zope', INFO,
- 'Beginning attempt to rebuild the global ZClass registry.')
+ logger.info('Beginning attempt to rebuild the global ZClass registry.')
app.fixupZClassDependencies(rebuild=1)
did_fixups=1
- LOG('Zope', INFO,
- 'The global ZClass registry has successfully been rebuilt.')
+ logger.info('The global ZClass registry has successfully been rebuilt.')
transaction.get().note('Rebuilt global product registry')
transaction.commit()
except:
bad_things=1
- LOG('Zope', ERROR, 'The attempt to rebuild the registry failed.',
- error=sys.exc_info())
+ logger.info('The attempt to rebuild the registry failed.',
+ exc_info=True)
transaction.abort()
# Now we need to see if any (disk-based) products were installed
@@ -594,18 +593,17 @@
# product was added or updated and we are not a ZEO client.
if getattr(Globals, '__disk_product_installed__', None):
try:
- LOG('Zope', INFO,
+ logger.info(
('New disk product detected, determining if we need '
- 'to fix up any ZClasses.'))
+ 'to fix up any ZClasses.'))
if app.fixupZClassDependencies():
- LOG('Zope',INFO,
- 'Repaired broken ZClass dependencies.')
+ logger.info('Repaired broken ZClass dependencies.')
self.commit('Repaired broked ZClass dependencies')
except:
- LOG('Zope', ERROR,
+ logger.error(
('Attempt to fixup ZClass dependencies after '
'detecting an updated disk-based product failed.'),
- error=sys.exc_info())
+ exc_info=True)
transaction.abort()
def install_products(self):
@@ -682,10 +680,13 @@
for priority, product_name, index, product_dir in products:
if done.has_key(product_name):
- LOG('OFS.Application', WARNING, 'Duplicate Product name',
- 'After loading Product %s from %s,\n'
- 'I skipped the one in %s.\n' % (
- `product_name`, `done[product_name]`, `product_dir`) )
+ logger.warning(('OFS.Application: '
+ 'Duplicate Product name:'
+ 'After loading Product %s from %s,\n'
+ 'I skipped the one in %s.\n'),
+ `product_name`,
+ `done[product_name]`,
+ `product_dir`)
continue
done[product_name]=product_dir
import_product(product_dir, product_name, raise_exc=debug_mode)
@@ -718,17 +719,15 @@
if type(v) is _st and have_module(v): v=modules[v]
modules[k]=v
except:
- exc = sys.exc_info()
if log_exc:
- LOG('Zope', ERROR, 'Could not import %s' % pname,
- error=exc)
+ logger.error('Could not import %s',pname,exc_info=True)
f=StringIO()
traceback.print_exc(100,f)
f=f.getvalue()
try: modules[pname].__import_error__=f
except: pass
if raise_exc:
- raise exc[0], exc[1], exc[2]
+ raise sys.exc_info()
finally:
exc = None
@@ -864,8 +863,8 @@
except:
if log_exc:
- LOG('Zope',ERROR,'Couldn\'t install %s' % product_name,
- error=sys.exc_info())
+ logger.error("Couldn't install %s",product_name,
+ exc_info=True)
transaction.abort()
if raise_exc:
raise
More information about the Zope-Checkins
mailing list