products/CPSRSS

changeset 225:ff458a7963b3

zLOG -> logging
author Georges Racinet on purity.racinet.fr <georges@racinet.fr>
date Sat, 13 Nov 2010 17:04:21 +0100
parents 63739d0cff44
children b126b9cc1e01
files RSSChannel.py RSSTool.py
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line diff
     1.1 --- a/RSSChannel.py
     1.2 +++ b/RSSChannel.py
     1.3 @@ -20,8 +20,7 @@
     1.4  """The RSS tool manages RSS channels and refreshes them.
     1.5  """
     1.6  
     1.7 -from zLOG import LOG, DEBUG
     1.8 -
     1.9 +import logging
    1.10  import time
    1.11  import urllib
    1.12  from urllib2 import ProxyHandler
    1.13 @@ -44,6 +43,8 @@
    1.14  
    1.15  from Products.CPSRSS.interfaces import IRSSChannel
    1.16  
    1.17 +logger = logging.getLogger(__name__)
    1.18 +
    1.19  # (Ultraliberal RSS Parser) referred to as URP in this code
    1.20  # http://feedparser.org/
    1.21  # This parser is required for RSSChannel to function properly
    1.22 @@ -180,17 +181,17 @@
    1.23          """Refresh if on lazy refresh and the delay has elapsed."""
    1.24  
    1.25          if not self.lazy_refresh: # acquired from parent (portal_rss)
    1.26 -            LOG('RSSChannel refresh', DEBUG, 'not on lazy refresh')
    1.27 +            logger.debug('Not on lazy refresh')
    1.28              self._refresh()
    1.29              return
    1.30          delay = self.refresh_delay # acquired from parent (portal_rss)
    1.31          now = int(time.time())
    1.32          if now - self._refresh_time > delay:
    1.33 -            LOG('RSSChannel refresh', DEBUG, ' refreshing')
    1.34 +            logger.debug('Refreshing %r', self.id)
    1.35              self._refresh()
    1.36          else:
    1.37 -            LOG('RSSChannel refresh', DEBUG, 'not refreshing (now=%s last=%s)' %
    1.38 -                (now, self._refresh_time))
    1.39 +            logger.debug("Not refreshing %r (now=%s last=%s)", self.id,
    1.40 +                         now, self._refresh_time)
    1.41  
    1.42      def _refresh(self):
    1.43          """Refresh the channels from its source."""
    1.44 @@ -219,13 +220,10 @@
    1.45                  data = feedparser.parse(url, None, None, handlers=handlers)
    1.46          except SGMLParseError, err:
    1.47              data = {'channel': {}, 'items': []}
    1.48 -            LOG('RSSChannel Error', DEBUG,
    1.49 -                'RSS/SGML parsing error while retrieving feed\n'
    1.50 -                +str(url)+'\n'+str(err))
    1.51 +            logger.warn('RSS/SGML parsing error for feed at %s: %s', url, err)
    1.52          except Timeout, err2:
    1.53              data = {'channel': {}, 'items': []}
    1.54 -            LOG('RSSChannel Error', DEBUG,
    1.55 -                'Timeout error while retrieving feed\n'+str(url)+'\n'+str(err2))
    1.56 +            logger.warn('Timeout retrieving feed at %s: %s', url, err2)
    1.57  
    1.58          if data.has_key('status') and data['status'] >= 400:
    1.59              # If the http request fails, the description field could contain
     2.1 --- a/RSSTool.py
     2.2 +++ b/RSSTool.py
     2.3 @@ -19,7 +19,7 @@
     2.4  """The RSS tool manages RSS channels and refreshes them.
     2.5  """
     2.6  
     2.7 -from zLOG import LOG, DEBUG
     2.8 +import logging
     2.9  from Globals import InitializeClass, DTMLFile
    2.10  from AccessControl import ClassSecurityInfo
    2.11  from OFS.Folder import Folder
    2.12 @@ -33,6 +33,8 @@
    2.13  
    2.14  from Products.CPSRSS.interfaces import IRSSTool
    2.15  
    2.16 +logger = logging.getLogger(__name__)
    2.17 +
    2.18  class RSSTool(UniqueObject, Folder):
    2.19      """RSS tool, a container for RSS channels that can refresh them."""
    2.20