changeset 2323:a43db0817020

Use stdlib's logging instead of prints.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sat, 23 Jun 2007 21:15:18 +0200
parents 4b4868ae88f0
children c142804478c7
files MoinMoin/events/__init__.py MoinMoin/events/jabbernotify.py
diffstat 2 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/events/__init__.py	Sat Jun 23 21:02:15 2007 +0200
+++ b/MoinMoin/events/__init__.py	Sat Jun 23 21:15:18 2007 +0200
@@ -9,6 +9,8 @@
     @license: GNU GPL, see COPYING for details.
 """
 
+import logging
+
 from MoinMoin import wikiutil
 from MoinMoin.util import pysupport
 from MoinMoin.wikiutil import PluginAttributeError
@@ -16,6 +18,12 @@
 # Create a list of extension actions from the package directory
 modules = pysupport.getPackageModules(__file__)
 
+# A module-wide Logger, don't use it from outside
+logger = logging.getLogger("events")
+logger.setLevel(logging.DEBUG)
+logger.addHandler(logging.StreamHandler())
+
+
 class Event(object):
     """A class handling information common to all events."""
     def __init__(self, request):
--- a/MoinMoin/events/jabbernotify.py	Sat Jun 23 21:02:15 2007 +0200
+++ b/MoinMoin/events/jabbernotify.py	Sat Jun 23 21:15:18 2007 +0200
@@ -19,7 +19,6 @@
 from MoinMoin.Page import Page
 from MoinMoin.user import User, getUserList
 import MoinMoin.events.notification as notification
-
 import MoinMoin.events as ev
     
 
@@ -60,9 +59,9 @@
             server.removeJIDFromRoster(request.cfg.secret, event.jid)        
                 
     except xmlrpclib.Error, err:
-        print _("XML RPC error: %s") % (str(err),)
+        ev.logger.error(_("XML RPC error: %s"), str(err))
     except Exception, err:
-        print _("Low-level communication error: $s") % (str(err),)
+        ev.logger.error(_("Low-level communication error: $s"), str(err))
 
 
 def _filter_subscriber_list(event, subscribers):
@@ -178,6 +177,6 @@
         server.send_notification(request.cfg.secret, jids, message)
         return True
     except xmlrpclib.Error, err:
-        print _("XML RPC error: %s") % (str(err),)
+        ev.logger.error(_("XML RPC error: %s"), str(err))
     except Exception, err:
-        print _("Low-level communication error: %s") % (str(err),)
+        ev.logger.error(_("Low-level communication error: %s"), str(err),)