[Zope-Checkins] SVN: Zope/trunk/lib/python/OFS/ zLOG -> logging
Andreas Jung
andreas at andreas-jung.com
Sun Jan 8 05:39:07 EST 2006
Log message for revision 41196:
zLOG -> logging
Changed:
U Zope/trunk/lib/python/OFS/Application.py
U Zope/trunk/lib/python/OFS/Cache.py
U Zope/trunk/lib/python/OFS/ObjectManager.py
U Zope/trunk/lib/python/OFS/subscribers.py
-=-
Modified: Zope/trunk/lib/python/OFS/Application.py
===================================================================
--- Zope/trunk/lib/python/OFS/Application.py 2006-01-08 10:30:04 UTC (rev 41195)
+++ Zope/trunk/lib/python/OFS/Application.py 2006-01-08 10:39:07 UTC (rev 41196)
@@ -16,6 +16,7 @@
"""
import os, sys, traceback
+from logging import getLogger
from cgi import escape
from StringIO import StringIO
from warnings import warn
@@ -34,7 +35,7 @@
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
@@ -44,6 +45,7 @@
from interfaces import IApplication
from misc_ import Misc_
+LOG = getLogger('Application')
class Application(Globals.ApplicationDefaultPermissions,
ZDOM.Root, Folder.Folder,
@@ -234,9 +236,7 @@
ob._register()
result=1
if not rebuild:
- LOG('Zope', INFO,
- 'Registered ZClass: %s' % ob.id
- )
+ LOG.info('Registered ZClass: %s' % ob.id)
# Include subobjects.
if hasattr(base, 'objectItems'):
m = list(ob.objectItems())
@@ -249,9 +249,8 @@
m = list(ps.methods.objectItems())
items.extend(m)
except:
- LOG('Zope', WARNING,
- 'Broken objects exist in product %s.' % product.id,
- error=sys.exc_info())
+ LOG.warn('Broken objects exist in product %s.' % product.id,
+ exc_info=sys.exc_info())
return result
@@ -263,11 +262,11 @@
try:
keys=list(self._p_jar.root()['ZGlobals'].keys())
except:
- LOG('Zope', ERROR,
+ LOG.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=sys.exc_info())
return 1
return 0
@@ -384,10 +383,9 @@
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'))
+ LOG.error('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',))
@@ -395,10 +393,8 @@
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 '
- 'error.'),
- error=sys.exc_info())
+ LOG.error('Could not add a /temp_folder mount point due to an '
+ 'error.', exc_info=sys.exc_info())
return
# Ensure that there is a transient object container in the temp folder
@@ -421,15 +417,13 @@
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))
+ LOG.warn('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))
+ LOG.warn('failed to use nonexistent "%s" script as '
+ 'session-delete-notify-script-path' % delnotify)
delnotify=None
toc = TransientObjectContainer(
@@ -572,17 +566,17 @@
bad_things=0
try:
if app.checkGlobalRegistry():
- LOG('Zope', INFO,
+ LOG.info(
'Beginning attempt to rebuild the global ZClass registry.')
app.fixupZClassDependencies(rebuild=1)
did_fixups=1
- LOG('Zope', INFO,
+ LOG.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.',
+ LOG.error('The attempt to rebuild the registry failed.',
error=sys.exc_info())
transaction.abort()
@@ -599,18 +593,15 @@
# product was added or updated and we are not a ZEO client.
if getattr(Globals, '__disk_product_installed__', None):
try:
- LOG('Zope', INFO,
- ('New disk product detected, determining if we need '
- 'to fix up any ZClasses.'))
+ LOG.info('New disk product detected, determining if we need '
+ 'to fix up any ZClasses.')
if app.fixupZClassDependencies():
- LOG('Zope',INFO,
- 'Repaired broken ZClass dependencies.')
+ LOG.info('Repaired broken ZClass dependencies.')
self.commit('Repaired broked ZClass dependencies')
except:
- LOG('Zope', ERROR,
- ('Attempt to fixup ZClass dependencies after '
- 'detecting an updated disk-based product failed.'),
- error=sys.exc_info())
+ LOG.error('Attempt to fixup ZClass dependencies after '
+ 'detecting an updated disk-based product failed.',
+ exc_info=sys.exc_info())
transaction.abort()
def install_products(self):
@@ -687,10 +678,10 @@
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`) )
+ LOG.warn('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)
@@ -725,8 +716,8 @@
except:
exc = sys.exc_info()
if log_exc:
- LOG('Zope', ERROR, 'Could not import %s' % pname,
- error=exc)
+ LOG.error('Could not import %s' % pname,
+ exc_info=exc)
f=StringIO()
traceback.print_exc(100,f)
f=f.getvalue()
@@ -869,8 +860,8 @@
except:
if log_exc:
- LOG('Zope',ERROR,'Couldn\'t install %s' % product_name,
- error=sys.exc_info())
+ LOG.error('Couldn\'t install %s' % product_name,
+ exc_info=sys.exc_info())
transaction.abort()
if raise_exc:
raise
Modified: Zope/trunk/lib/python/OFS/Cache.py
===================================================================
--- Zope/trunk/lib/python/OFS/Cache.py 2006-01-08 10:30:04 UTC (rev 41195)
+++ Zope/trunk/lib/python/OFS/Cache.py 2006-01-08 10:39:07 UTC (rev 41196)
@@ -15,11 +15,12 @@
$Id$
"""
import time, sys
+from logging import getLogger
import Globals
from Globals import InitializeClass
from Globals import DTMLFile
from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base
-from zLOG import LOG, WARNING
+
from AccessControl import ClassSecurityInfo
from AccessControl import getSecurityManager
from AccessControl.Role import _isBeingUsedAsAMethod
@@ -30,6 +31,7 @@
ViewManagementScreensPermission = view_management_screens
ChangeCacheSettingsPermission = 'Change cache settings'
+LOG = getLogger('Cache')
def isCacheable(ob):
@@ -186,8 +188,8 @@
mtime_func, default)
return val
except:
- LOG('Cache', WARNING, 'ZCache_get() exception',
- error=sys.exc_info())
+ LOG.warn('ZCache_get() exception',
+ exc_info=sys.exc_info())
return default
return default
@@ -204,8 +206,8 @@
c.ZCache_set(ob, data, view_name, keywords,
mtime_func)
except:
- LOG('Cache', WARNING, 'ZCache_set() exception',
- error=sys.exc_info())
+ LOG.warn('ZCache_set() exception',
+ exc_info=sys.exc_info())
security.declareProtected(ViewManagementScreensPermission,
'ZCacheable_invalidate')
@@ -224,8 +226,8 @@
except:
exc = sys.exc_info()
try:
- LOG('Cache', WARNING, 'ZCache_invalidate() exception',
- error=exc)
+ LOG.warn('ZCache_invalidate() exception',
+ exc_info=exc)
message = 'An exception occurred: %s: %s' % exc[:2]
finally:
exc = None
Modified: Zope/trunk/lib/python/OFS/ObjectManager.py
===================================================================
--- Zope/trunk/lib/python/OFS/ObjectManager.py 2006-01-08 10:30:04 UTC (rev 41195)
+++ Zope/trunk/lib/python/OFS/ObjectManager.py 2006-01-08 10:39:07 UTC (rev 41196)
@@ -685,8 +685,8 @@
try:
stat=marshal.loads(v.manage_FTPstat(REQUEST))
except:
- LOG("FTP", ERROR, "Failed to stat file '%s'" % k,
- error=sys.exc_info())
+ LOG.error("Failed to stat file '%s'" % k,
+ exc_info=sys.exc_info())
stat=None
if stat is not None:
out=out+((k,stat),)
Modified: Zope/trunk/lib/python/OFS/subscribers.py
===================================================================
--- Zope/trunk/lib/python/OFS/subscribers.py 2006-01-08 10:30:04 UTC (rev 41195)
+++ Zope/trunk/lib/python/OFS/subscribers.py 2006-01-08 10:39:07 UTC (rev 41196)
@@ -19,8 +19,8 @@
import warnings
import sys
+from logging import getLogger
-from zLOG import LOG, ERROR
from Acquisition import aq_base
from App.config import getConfiguration
from AccessControl import getSecurityManager
@@ -35,6 +35,7 @@
deprecatedManageAddDeleteClasses = []
+LOG = getLogger('OFS.subscribers')
def compatibilityCall(method_name, *args):
"""Call a method if events have not been setup yet.
@@ -152,7 +153,7 @@
except ConflictError:
raise
except:
- LOG('Zope', ERROR, '_delObject() threw', error=sys.exc_info())
+ LOG.error('_delObject() threw', exc_info=sys.exc_info())
# In debug mode when non-Manager, let exceptions propagate.
if getConfiguration().debug_mode:
if not getSecurityManager().getUser().has_role('Manager'):
More information about the Zope-Checkins
mailing list