semvec/pypi-packages huggingface dataset:
asynmsg 0.2.4
A library help to build tcp server/client application

asynmsg
=======

A library based on asyncore, used to build tcp server/client application communicating each other with customized messages.

Examples
--------

Server::

    import asynmsg

    @asynmsg.with_message_handler_config
    class ServerSession(asynmsg.SessionS):

        @asynmsg.message_handler_config('Login')
        def on_Login(self, msg_id, msg_data):
            self.send_message('LoginAck', 'login success')

    class Server(asynmsg.Server):
        session_class = ServerSession

    Server(('127.0.0.1', 12345))
    asynmsg.run_forever()

Client::

    import asynmsg

    @asynmsg.with_message_handler_config
    class ClientSession(asynmsg.SessionC):
        def on_opened(self):
            asynmsg.SessionC.on_opened(self)
            self.send_message('Login', 'test1')

        @asynmsg.message_handler_config('LoginAck')
        def on_LoginAck(self, msg_id, msg_data):
            pass

    class Client(asynmsg.ClientBlockConnect):
        session_class = ClientSession

    client = Client(('127.0.0.1', 12345))
    if client.is_started():
        asynmsg.run_forever()
logbind 2017.11.7
logbind

.. image:: https://travis-ci.org/cjrh/logbind.svg?branch=master
    :target: https://travis-ci.org/cjrh/logbind

.. image:: https://coveralls.io/repos/github/cjrh/logbind/badge.svg?branch=master
    :target: https://coveralls.io/github/cjrh/logbind?branch=master

.. image:: https://img.shields.io/pypi/pyversions/logbind.svg
    :target: https://pypi.python.org/pypi/logbind

.. image:: https://img.shields.io/github/tag/cjrh/logbind.svg
    :target: https://img.shields.io/github/tag/cjrh/logbind.svg

.. image:: https://img.shields.io/badge/install-pip%20install%20logbind-ff69b4.svg
    :target: https://img.shields.io/badge/install-pip%20install%20logbind-ff69b4.svg

.. image:: https://img.shields.io/pypi/v/logbind.svg
    :target: https://img.shields.io/pypi/v/logbind.svg

.. image:: https://img.shields.io/badge/calver-YYYY.MM.MINOR-22bfda.svg
    :target: http://calver.org/


logbind
======================

Easily bind new fields into your logger instances.

.. code-block:: python

    # Original logger
    logger = logging.getLogger('a')
    logger.info('Hello')

    logger = logbind.bind(logger, id=12345)
    logger.info('Hello')  # <- This logrecord has an extra field "id"

    logger = logbind.bind(logger, abc=67890)
    logger.info('Hello')  # <- logrecord has two extra fields: "id" and "abc"


This feature will be most useful with a structured logging formatter,
such as JSON.  You could try `logjson <https://github.com/cjrh/logjson>`_
for example.