# HG changeset patch # User Dirk Olmes # Date 1272392302 -7200 # Node ID e87c54b3a216eb9c43e1e1934d48e0aa774d6c01 # Parent 01a86b178e6009d40f7bb3ddf359f68d4caf1d7b use the logging framework for printing messages diff -r 01a86b178e60 -r e87c54b3a216 FeedUpdater.py --- a/FeedUpdater.py Tue Apr 27 20:08:21 2010 +0200 +++ b/FeedUpdater.py Tue Apr 27 20:18:22 2010 +0200 @@ -3,8 +3,10 @@ from Feed import Feed from FeedEntry import FeedEntry import feedparser +import logging STATUS_OK = 200 +logger = logging.getLogger("FeedUpdater") def updateAllFeeds(session): allFeeds = session.query(Feed) @@ -12,7 +14,7 @@ try: FeedUpdater(session, feed).update() except FeedUpdateException: - print("problems while updating feed " + feed.rss_url) + logger.warn("problems while updating feed " + feed.rss_url) session.commit() class FeedUpdater(object): diff -r 01a86b178e60 -r e87c54b3a216 feedupdate-main.py --- a/feedupdate-main.py Tue Apr 27 20:08:21 2010 +0200 +++ b/feedupdate-main.py Tue Apr 27 20:18:22 2010 +0200 @@ -4,10 +4,13 @@ from Feed import Feed from FeedUpdater import updateAllFeeds import Mapping +import logging import socket from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker +logger = logging.getLogger("feedupdater") + def loadDatabaseProperties(): hostname = socket.gethostname() filename = "database-%s.ini" % hostname @@ -25,7 +28,7 @@ def listFeeds(session): allFeeds = session.query(Feed) for feed in allFeeds: - print "\n\nfeed: " + feed.name + logger.info("feed: " + feed.name) for entry in feed.entries: print entry.title