%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python2.7/site-packages/zmq/log/
Upload File :
Create Path :
Current File : //lib64/python2.7/site-packages/zmq/log/handlers.pyo

�
+�{Wc@s�dZddlZddlmZmZmZmZmZddlZddlm	Z	m
Z
mZdZdej
fd��YZdejfd	��YZx9d
j�D]+Zeeje�Zeeed��q�WdS(snpyzmq logging handlers.

This mainly defines the PUBHandler object for publishing logging messages over
a zmq.PUB socket.

The PUBHandler can be used with the regular logging module, as in::

    >>> import logging
    >>> handler = PUBHandler('tcp://127.0.0.1:12345')
    >>> handler.root_topic = 'foo'
    >>> logger = logging.getLogger('foobar')
    >>> logger.setLevel(logging.DEBUG)
    >>> logger.addHandler(handler)

After this point, all messages logged by ``logger`` will be published on the
PUB socket.

Code adapted from StarCluster:

    http://github.com/jtriley/StarCluster/blob/master/starcluster/logger.py
i����N(tINFOtDEBUGtWARNtERRORtFATAL(tbytestunicodet
cast_bytess::t
PUBHandlercBs�eZdZdZdZiejd�ej6ejd�ej	6ejd�ej
6ejd�ej6ejd�ej6Z
dd�Zd�Zd�ZRS(	s|A basic logging handler that emits log messages through a PUB socket.

    Takes a PUB socket already bound to interfaces or an interface to bind to.

    Example::

        sock = context.socket(zmq.PUB)
        sock.bind('inproc://log')
        handler = PUBHandler(sock)

    Or::

        handler = PUBHandler('inproc://loc')

    These are equivalent.

    Log messages handled by this handler are broadcast with ZMQ topics
    ``this.root_topic`` comes first, followed by the log level
    (DEBUG,INFO,etc.), followed by any additional subtopics specified in the
    message by: log.debug("subtopic.subsub::the real message")
    ts4%(levelname)s %(filename)s:%(lineno)d - %(message)s
s%(message)s
sC%(levelname)s %(filename)s:%(lineno)d - %(message)s - %(exc_info)s
cCs~tjj|�t|tj�r=||_|jj|_n=|pLtj	�|_|jjtj
�|_|jj|�dS(N(tloggingtHandlert__init__t
isinstancetzmqtSockettsockettcontexttctxtContexttPUBtbind(tselftinterface_or_socketR((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyRIs	cCs|j|jj|�S(sFormat a record.(t
formatterstlevelnotformat(Rtrecord((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyRSscCs�y"|jjtd�\}|_Wntk
r;d}nXyt|j|��}Wntk
rv|j|�dSXg}|jr�|j|j�n|j|j	�|r�|j|�ndj
d�|D��}|jj||g�dS(s Emit a log message on my socket.iR	Nt.css|]}t|�VqdS(N(R(t.0tt((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pys	<genexpr>ms(
tmsgtsplittTOPIC_DELIMt	ExceptionRRthandleErrort
root_topictappendt	levelnametjoinRtsend_multipart(RRttopictbmsgt
topic_listtbtopic((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pytemitWs""



	N(t__name__t
__module__t__doc__R$tNoneRR
t	FormatterRRRRtCRITICALRRRR-(((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyR%s 



	tTopicLoggercBseZdZd�ZRS(s A simple wrapper that takes an additional argument to log methods.

    All the regular methods exist, but instead of one msg argument, two
    arguments: topic, msg are passed.

    That is::

        logger.debug('msg')

    Would become::

        logger.debug('topic.sub', 'msg')
    cOs*tjj||d||f||�dS(sLog 'msg % args' with level and topic.

        To pass exception information, use the keyword argument exc_info
        with a True value::

            logger.log(level, "zmq.fun", "We have a %s", 
                    "mysterious problem", exc_info=1)
        s%s::%sN(R
tLoggertlog(RtlevelR)Rtargstkwargs((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyR6�s	(R.R/R0R6(((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyR4rs
s'debug warn warning error critical fatalcOst|||t|||�S(N(tmethR!(RR7R)RR8R9((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyt<lambda>�s(R0R
RRRRRRtzmq.utils.strtypesRRRR!RRR5R4R tnametgetattrR:tsetattr(((s6/usr/lib64/python2.7/site-packages/zmq/log/handlers.pyt<module>s(M	

Zerion Mini Shell 1.0