HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/site-packages/zmq/log/__pycache__/handlers.cpython-36.pyc
3

VS�_@�@s�dZddlZddlmZmZmZmZmZddlZddlm	Z	m
Z
mZdZGdd�dej
�ZGdd	�d	ej�Zx,d
j�D] Zeeje�Zeeedd��qvWdS)
anpyzmq 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
�N)�INFO�DEBUG�WARN�ERROR�FATAL)�bytes�unicode�
cast_bytesz::c@s^eZdZdZdZddd�Zedd��Zejdd��Zd	d
�Z	e
jfdd�Zd
d�Z
dd�ZdS)�
PUBHandlera|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")
    N�cCs�tjj|�||_tjtjd�tjtjd�tjtjd�tjtjd�tj	tjd�i|_
t|tj
�rr||_|jj|_n*|p|tj�|_|jjtj�|_|jj|�dS)Nz4%(levelname)s %(filename)s:%(lineno)d - %(message)s
z%(message)s
zC%(levelname)s %(filename)s:%(lineno)d - %(message)s - %(exc_info)s
)�logging�Handler�__init__�_root_topicrZ	FormatterrrrZCRITICAL�
formatters�
isinstance�zmqZSocket�socket�contextZctxZContextZPUBZbind)�selfZinterface_or_socketr�
root_topic�r� /usr/lib64/python3.6/handlers.pyr?s"
zPUBHandler.__init__cCs|jS)N)r)rrrrrTszPUBHandler.root_topiccCs|j|�dS)N)�setRootTopic)r�valuerrrrXscCs
||_dS)a|Set the root topic for this handler.

        This value is prepended to all messages published by this handler, and it
        defaults to the empty string ''. When you subscribe to this socket, you must
        set your subscription to an empty string, or to at least the first letter of
        the binary representation of this string to ensure you receive any messages
        from this handler.

        If you use the default empty string root topic, messages will begin with
        the binary representation of the log level string (INFO, WARN, etc.).
        Note that ZMQ SUB sockets can have multiple subscriptions.
        N)r)rrrrrr\s
zPUBHandler.setRootTopiccCs8|tjkr*x(|jj�D]}||j|<qWn
||j|<dS)z�Set the Formatter for this handler.

        If no level is provided, the same format is used for all levels. This
        will overwrite all selective formatters set in the object constructor.
        N)r�NOTSETr�keys)rZfmt�levelZ	fmt_levelrrr�setFormatterks
zPUBHandler.setFormattercCs|j|jj|�S)zFormat a record.)rZlevelno�format)r�recordrrrrwszPUBHandler.formatcCs�y|jjtd�\}|_Wntk
r0d}YnXyt|j|��}Wntk
rb|j|�dSXg}|jrz|j|j�|j|j	�|r�|j|�dj
dd�|D��}|jj||g�dS)z Emit a log message on my socket.�rN�.css|]}t|�VqdS)N)r	)�.0�trrr�	<genexpr>�sz"PUBHandler.emit.<locals>.<genexpr>)
�msg�split�TOPIC_DELIM�	Exceptionr	rZhandleErrorr�appendZ	levelname�joinrZsend_multipart)rr �topicZbmsgZ
topic_listZbtopicrrr�emit{s"


zPUBHandler.emit)Nr)�__name__�
__module__�__qualname__�__doc__rr�propertyr�setterrrrrrr-rrrrr
%s
r
c@seZdZdZdd�ZdS)�TopicLoggera 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||ff|�|�dS)aLog '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)
        z%s::%sN)r�Logger�log)rrr,r&�args�kwargsrrrr6�s	zTopicLogger.logN)r.r/r0r1r6rrrrr4�s
r4z'debug warn warning error critical fatalcOst|||t|f|�|�S)N)�methr()rrr,r&r7r8rrr�<lambda>�sr:)r1rrrrrrrZzmq.utils.strtypesrrr	r(r
r
r5r4r'�name�getattrr9�setattrrrrr�<module>sq