Commit a62db5fe authored by Chris Withers's avatar Chris Withers

Move to python logging module.

parent fd6f0a3f
......@@ -21,6 +21,7 @@ from StringIO import StringIO
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 DateTime import DateTime
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 FindSupport import FindSupport
from interfaces import IApplication
from misc_ import Misc_
logger = logging.getLogger('Zope')
class Application(Globals.ApplicationDefaultPermissions,
ZDOM.Root, Folder.Folder,
......@@ -231,9 +232,7 @@ class Application(Globals.ApplicationDefaultPermissions,
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 @@ class Application(Globals.ApplicationDefaultPermissions,
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 @@ class Application(Globals.ApplicationDefaultPermissions,
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 @@ class AppInitializer:
# 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,8 +378,9 @@ class AppInitializer:
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 '
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
......@@ -390,10 +390,11 @@ class AppInitializer:
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 @@ class AppInitializer:
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 @@ class AppInitializer:
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 @@ class AppInitializer:
# 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.'))
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 @@ def import_products():
for priority, product_name, index, product_dir in products:
if done.has_key(product_name):
LOG('OFS.Application', WARNING, 'Duplicate Product name',
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`) )
'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 @@ def import_product(product_dir, product_name, raise_exc=0, log_exc=1):
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 @@ def install_product(app, product_dir, product_name, meta_types,
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment