def get_log_handler(self, socket_name, topic_name='logs'):
"""returns an instance of :py:class:ZMQPubHandler attached to a previously-created socket.
:param socket_name: the name of the socket, previously created with :py:meth:SocketManager.create
:param topic_name: the name of the topic in which the logs will be PUBlished
**Example:**
::
>>> import zmq
>>> from agentzero.core import SocketManager
>>>
>>> sockets = SocketManager()
>>> sockets.ensure_and_bind('logs', zmq.PUB, 'tcp://*:6000', zmq.POLLOUT)
>>> app_logger = sockets.get_logger('logs', logger_name='myapp'))
>>> app_logger.info("Server is up!")
>>> try:
url = sockets.recv_safe('download_queue')
... requests.get(url)
... except:
... app_logger.exception('failed to download url: %s', url)
"""
return ZMQPubHandler(self, socket_name, topic_name)
评论列表
文章目录