403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/zmq/log/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/zmq/log/__pycache__/handlers.cpython-310.pyc
o

;j<�	@s�dZddlmZddlZddlmZddlZdZGdd�dej�ZGdd	�d	ej	�Z
d
��D]Zze
ej	e�ZWn	eyAYq.wee
edd��q.dS)
a�pyzmq 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)

Or using ``dictConfig``, as in::

    >>> from logging.config import dictConfig
    >>> socket = Context.instance().socket(PUB)
    >>> socket.connect('tcp://127.0.0.1:12345')
    >>> dictConfig({
    >>>     'version': 1,
    >>>     'handlers': {
    >>>         'zmq': {
    >>>             'class': 'zmq.log.handlers.PUBHandler',
    >>>             'level': logging.DEBUG,
    >>>             'root_topic': 'foo',
    >>>             'interface_or_socket': socket
    >>>         }
    >>>     },
    >>>     'root': {
    >>>         'level': 'DEBUG',
    >>>         'handlers': ['zmq'],
    >>>     }
    >>> })


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

Code adapted from StarCluster:

    https://github.com/jtriley/StarCluster/blob/StarCluster-0.91/starcluster/logger.py
�)�annotationsN)�copyz::c@sxeZdZUdZded<ded<		dddd�Zed dd��Zejd!dd��Zd"dd�Z	e
jfdd�Zdd�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")
    zzmq.Context�ctxz
zmq.Socket�socketN��interface_or_socket�str | zmq.Socket�context�zmq.Context | None�
root_topic�str�return�NonecCs�tj�|�||_tjt�d�tjt�d�tjt�d�tjt�d�tj	t�d�i|_
t|tj
�r:||_|jj|_dS|p?t��|_|j�tj�|_|j�|�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__r�DEBUG�	Formatter�INFO�WARN�ERROR�CRITICAL�
formatters�
isinstance�zmqZSocketrr
rZContextZPUB�bind)�selfrr
r�r�D/opt/saltstack/salt/lib/python3.10/site-packages/zmq/log/handlers.pyrUs,�����zPUBHandler.__init__cCs|jS�N)�_root_topic)rrrrrtszPUBHandler.root_topic�valuecCs|�|�dSr )�setRootTopic)rr"rrrrxscCst|t�r
|�d�}||_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.
        �utf8N)r�bytes�decoder!)rrrrrr#|s


zPUBHandler.setRootTopiccCs6|tjkr|j��D]}||j|<q
dS||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)r�fmt�levelZ	fmt_levelrrr�setFormatter�s

�zPUBHandler.setFormattercCs|j|j�|�S)zFormat a record.)r�levelno�format)r�recordrrrr-�szPUBHandler.formatcCs�z
t|j��td�\}}Wntyd}Ynwt|�}||_z
|�|��d�}Wnty9|�	|�YdSwg}|j
rE|�|j
�|�|j�|rR|�|�d�
|��dd�}|j�||g�dS)z Emit a log message on my socket.�rr$N�.�replace)r
�msg�split�TOPIC_DELIM�
ValueErrorrr-�encode�	Exception�handleErrorr�append�	levelname�joinrZsend_multipart)rr.�topicr2ZbmsgZ
topic_listZbtopicrrr�emit�s*�
�
zPUBHandler.emit)Nr)rr	r
rrr
rr)rr
)r"r
)rr
)�__name__�
__module__�__qualname__�__doc__�__annotations__r�propertyr�setterr#rr'r+r-r=rrrrr;s
�
rc@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|||�t�|��g|�Ri|��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)
        N)r�Logger�logr4�rr*r<r2�args�kwargsrrrrG�s.	zTopicLogger.logN)r>r?r@rArGrrrrrE�srEz'debug warn warning error critical fatalcOs"t|||t|g|�Ri|��Sr )�methr4rHrrr�<lambda>�s���rL)rA�
__future__rrrrr4rrrFrEr3�name�getattrrK�AttributeError�setattrrrrr�<module>s*,���

Youez - 2016 - github.com/yon3zu
LinuXploit