PK]o 7zÎ9芊xmllayout/__init__.py"""XMLLayout Formatter and RawSocketHandler""" from xmllayout.formatters import XMLLayout from xmllayout.handlers import RawSocketHandler PK¹† 7†¾È11xmllayout/handlers.py"""logging Handlers""" import logging.handlers __all__ = ['RawSocketHandler'] class RawSocketHandler(logging.handlers.SocketHandler): """Logging Handler that writes log records to a streaming socket. Like ``logging.handlers.SocketHandler``, but writes the actual formatted log record (not a pickled version). """ def emit(self, record): """Emit a record. Formats the record and writes it to the socket in binary format. If there is an error with the socket, silently drop the packet. If there was a problem with the socket, re-establishes the socket. """ try: msg = self.format(record) self.send(msg) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) PK™f7ðŒ`‘ ‘ xmllayout/formatters.py"""logging Formatters""" import cgi import logging __all__ = ['XMLLayout'] class XMLLayout(logging.Formatter): """Formats log Records as XML according to the `log4j XMLLayout _` """ def format(self, record): """Format the log record as XMLLayout XML""" event = dict(name=cgi.escape(record.name), threadName=cgi.escape(record.threadName), levelname=cgi.escape(record.levelname), created=int(record.created * 1000)) event['message'] = LOG4J_MESSAGE % escape_cdata(record.getMessage()) # FIXME: Support an NDC somehow event['ndc'] = '' #ndc = self.get_ndc(record) #if ndc: # event['ndc'] = LOG4J_NDC % escape_cdata(ndc) event['throwable'] = '' if record.exc_info: if not record.exc_text: record.exc_text = self.formatException(record.exc_info) event['throwable'] = LOG4J_THROWABLE % escape_cdata(record.exc_text) location_info = dict(pathname=cgi.escape(record.pathname), lineno=record.lineno, module=cgi.escape(record.module), funcName='') if hasattr(record, 'funcName'): # >= Python 2.5 location_info['funcName'] = cgi.escape(record.funcName) event['locationInfo'] = LOG4J_LOCATIONINFO % location_info return LOG4J_EVENT % event def escape_cdata(cdata): return cdata.replace(']]>', ']]>]]> %(message)s%(ndc)s%(throwable)s%(locationInfo)s """ # The actual log message LOG4J_MESSAGE = """\ """ # log4j's 'Nested Diagnostic Context': additional, customizable information # included with the log record LOG4J_NDC = """\ """ # Exception information, if exc_info was included with the record LOG4J_THROWABLE = """\ """ # Traceback information LOG4J_LOCATIONINFO = """\ """ PKh7éW”€ŽŽxmllayout/__init__.pyc;ò “t¿Fc@s$dZdklZdklZdS(s(XMLLayout Formatter and RawSocketHandler(s XMLLayout(sRawSocketHandlerN(s__doc__sxmllayout.formatterss XMLLayoutsxmllayout.handlerssRawSocketHandler(s XMLLayoutsRawSocketHandler((s>build/bdist.freebsd-6.2-RELEASE-i386/egg/xmllayout/__init__.pys?s PKh7ÄÚ2‹‹xmllayout/handlers.pyc;ò ©»Fc@s8dZdkZdgZdeiifd„ƒYZdS(slogging HandlersNsRawSocketHandlercBstZdZd„ZRS(s¹Logging Handler that writes log records to a streaming socket. Like ``logging.handlers.SocketHandler``, but writes the actual formatted log record (not a pickled version). cCsVy |i|ƒ}|i|ƒWn/ttfj o ‚n|i|ƒnXdS(sôEmit a record. Formats the record and writes it to the socket in binary format. If there is an error with the socket, silently drop the packet. If there was a problem with the socket, re-establishes the socket. N(sselfsformatsrecordsmsgssendsKeyboardInterrupts SystemExits handleError(sselfsrecordsmsg((s>build/bdist.freebsd-6.2-RELEASE-i386/egg/xmllayout/handlers.pysemit s(s__name__s __module__s__doc__semit(((s>build/bdist.freebsd-6.2-RELEASE-i386/egg/xmllayout/handlers.pysRawSocketHandlers (s__doc__slogging.handlerssloggings__all__shandlerss SocketHandlersRawSocketHandler(sRawSocketHandlersloggings__all__((s>build/bdist.freebsd-6.2-RELEASE-i386/egg/xmllayout/handlers.pys?s  PKh7 •7§ xmllayout/formatters.pyc;ò “ŸÈFc@sedZdkZdkZdgZdeifd„ƒYZd„ZdZdZdZ dZ d Z dS( slogging FormattersNs XMLLayoutcBstZdZd„ZRS(s›Formats log Records as XML according to the `log4j XMLLayout _` c CsItdti|iƒdti|iƒdti|iƒdt|idƒƒ}t t |i ƒƒ|ds]]>]]> %(message)s%(ndc)s%(throwable)s%(locationInfo)s s2 s* s6 s ( s__doc__scgisloggings__all__s Formatters XMLLayouts escape_cdatas LOG4J_EVENTs LOG4J_MESSAGEs LOG4J_NDCsLOG4J_THROWABLEsLOG4J_LOCATIONINFO( scgisLOG4J_LOCATIONINFOsloggings LOG4J_NDCs__all__s escape_cdatas LOG4J_EVENTs LOG4J_MESSAGEsLOG4J_THROWABLEs XMLLayout((s@build/bdist.freebsd-6.2-RELEASE-i386/egg/xmllayout/formatters.pys?s   %  PKh7®j®™[[EGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: XMLLayout Version: 0.3 Summary: Formats Python log messages as log4j XMLLayout XML Home-page: http://pypi.python.org/pypi/XMLLayout Author: Philip Jenvey Author-email: pjenvey@groovie.org License: BSD Description: XMLLayout provides a Python logging Formatter that formats log messages as XML, according to `log4j's XMLLayout specification `_. XMLLayout formatted log messages can be viewed and filtered within the `Chainsaw `_ application (see the example section below), part of the Java based log4j project. This package also includes a RawSocketHandler -- like logging.handler.SocketHandler, but sends the raw log message over the socket instead of a pickled version. RawSocketHandler can be configured to send log messages to Chainsaw directly over a socket. For example: to forward log messages to Chainsaw, if it were listening on localhost port 4448:: import logging import xmllayout handler = xmllayout.RawSocketHandler('localhost', 4448) handler.setFormatter(xmllayout.XMLLayout()) logging.root.addHandler(handler) Keywords: logging log4j Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Programming Language :: Python Classifier: Topic :: System :: Logging PKh7!#ÿÝññEGG-INFO/SOURCES.txtsetup.py XMLLayout.egg-info/PKG-INFO XMLLayout.egg-info/SOURCES.txt XMLLayout.egg-info/dependency_links.txt XMLLayout.egg-info/not-zip-safe XMLLayout.egg-info/top_level.txt xmllayout/__init__.py xmllayout/formatters.py xmllayout/handlers.py PKh7“×2EGG-INFO/dependency_links.txt PKº€ 7“×2EGG-INFO/not-zip-safe PKh7ÏùÍ EGG-INFO/top_level.txtxmllayout PK]o 7zÎ9芊¤xmllayout/__init__.pyPK¹† 7†¾È11¤½xmllayout/handlers.pyPK™f7ðŒ`‘ ‘ ¤!xmllayout/formatters.pyPKh7éW”€ŽŽ¤ç xmllayout/__init__.pycPKh7ÄÚ2‹‹¤©xmllayout/handlers.pycPKh7 •7§ ¤hxmllayout/formatters.pycPKh7®j®™[[¤ž EGG-INFO/PKG-INFOPKh7!#ÿÝññ¤('EGG-INFO/SOURCES.txtPKh7“×2¤K(EGG-INFO/dependency_links.txtPKº€ 7“×2¤‡(EGG-INFO/not-zip-safePKh7ÏùÍ ¤»(EGG-INFO/top_level.txtPK ìù(