File: //lib64/python3.6/site-packages/zmq/log/__pycache__/handlers.cpython-36.pyc
3
VS�_@ � @ s� d Z ddlZddlmZmZmZmZmZ ddlZddlm Z m
Z
mZ dZG dd� dej
�ZG dd � d ej�Zx,d
j� D ] Zeeje�Zeeedd� � qvW dS )
an 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)
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^ e Zd ZdZdZddd�Zedd� �Zejdd� �Zd d
� Z e
jfdd�Zd
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� c C s� t jj| � || _t jt jd�t jt jd�t jt jd�t jt jd�t j t jd�i| _
t|tj
�rr|| _| jj| _n*|p|tj� | _| jjtj�| _| jj|� d S )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_topicr Z Formatterr r r ZCRITICAL�
formatters�
isinstance�zmqZSocket�socket�contextZctxZContextZPUBZbind)�selfZinterface_or_socketr �
root_topic� r � /usr/lib64/python3.6/handlers.pyr ? s"