[Zope-Checkins] CVS: Zope3/lib/python/Zope/Event - Logger.py:1.1.2.1
Chris Withers
chrisw@nipltd.com
Sat, 23 Feb 2002 14:38:28 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Event
In directory cvs.zope.org:/tmp/cvs-serv29832
Added Files:
Tag: Zope-3x-branch
Logger.py
Log Message:
Added Event Logger as a sample (but useful ;-) implementation of ISubscriber.
=== Added File Zope3/lib/python/Zope/Event/Logger.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Revision information:
$Id: Logger.py,v 1.1.2.1 2002/02/23 19:38:27 chrisw Exp $
"""
from ISubscriber import ISubscriber
from zLOG import LOG,BLATHER
from pprint import pprint
from StringIO import StringIO
class Logger:
__implements__ = ISubscriber
def __init__(self,severity=BLATHER):
self.severity = severity
def notify(self, event):
c = event.__class__
detail = StringIO()
pprint (event.__dict__,detail)
LOG('Event.Logger',
self.severity,
c.__module__+'.'+c.__name__,
detail.getvalue())