Metadata-Version: 1.0
Name: collective.recipe.logger
Version: 0.1.0b1
Summary: This recipe logs an information into storage. It's a part of https://github.com/potar/dagger
Home-page: http://github.com/potar/collective.recipe.logger
Author: Poburynnyi Taras (potar)
Author-email: poburynnyitaras@gmail.com
License: GPL
Description: Introduction
        ============
        
        This recipe creates the program daemon (logger) which is listening to the socket.
        It generates logs in an appropriate format (JSON, CSV, PICKLE).
        
        Example usage
        -------------
        The simplest way to use this recipe is to add it to your ``buildout.cfg`` like this::
        
            [buildout]
            parts = logger
        
            [logger]
            recipe = collective.recipe.backup
        
        
        Go to ``collective/recipe/logger/README.rst`` to see more details.
        
        
        Development
        -----------
        
        - Code repository: https://github.com/potar/collective.recipe.logger
        
        - The code comes with a ``buildout.cfg``.  Please bootstrap the
          buildout and run the created ``bin/test`` to see if the tests still
          pass.  Please add tests if you add code.
        
        - Questions and comments send to the Plone product-developers list or to
          potar: poburynnyitaras@gmail.com
        
        Supported options
        -----------------
        The recipe supports the following options (none of which are needed by default):
        
        **ip**
            It's a host ip. Default value: localhost
        
        **port**
            It's an application (daemon) port.
            Default value: 8090 (DEFAULT_TCP_LOGGING_PORT)
        
        **maxlen**
            It's a circular buffer size.
            Default value: 100. It means that you can store 100 records into storage.
        
        **mode**
            It's file mode bits which is intended to the file storage.
            Default value: 0644
        
        **format**
            It's a storage type.
            Options: 'csv', 'json', 'pickle'.
            Default value: 'json'
        
        **eggs**
            It sets up additional products. They help serialize objects.
            For example, your object will not be a standard python collection so you need an appropriate class for this object.
            If you use Plone I recommend you set up ``eggs = ${instance:eggs}``
        
        
        Notes
        -----
        
        * A storage filename is generated by id_generator (``src/collective/recipe/logger/utils.py``).
        
        Detailed Documentation
        **********************
        
        Example usage
        =============
        
        Some needed imports::
        
            >>> import re
            >>> import os
            >>> import time
            >>> from multiprocessing.connection import Client
        
        We'll start by creating a simple ``buildout.cfg`` that uses the recipe::
        
            >>> write('buildout.cfg',
            ... """
            ... [buildout]
            ... parts = logger
            ... # For some reason this is now needed:
            ... index = http://b.pypi.python.org/simple
            ... newest = false
            ...
            ... [logger]
            ... recipe = collective.recipe.logger
            ... """)
        
        Running the buildout gives us::
        
            >>> print system(buildout)
            Getting distribution for 'zc.recipe.egg'.
            Got zc.recipe.egg 1.3.2.
            Installing logger.
            Generated script '/sample-buildout/bin/logger'.
            <BLANKLINE>
        
        Let's test the daemon::
        
            >>> print system('bin/logger start')
            Starting...
            <BLANKLINE>
        
            >>> status_info = system('bin/logger status')
            >>> bool(re.match('Daemon \(pid=\d+\) is already running', status_info))
            True
        
            >>> print system('bin/logger stop')
            Stopping...
            Stopped
            <BLANKLINE>
        
        Set up more complex example::
        
            >>> write('buildout.cfg',
            ... """
            ... [buildout]
            ... parts = logger
            ... # For some reason this is now needed:
            ... index = http://b.pypi.python.org/simple
            ... newest = false
            ...
            ... [logger]
            ... recipe = collective.recipe.logger
            ... ip = 127.0.0.1
            ... port = 8091
            ... maxlen = 10
            ... format = json
            ... """)
        
        Running the buildout gives us::
        
            >>> print system(buildout)
            Uninstalling logger.
            Installing logger.
            Generated script '/sample-buildout/bin/logger'.
            <BLANKLINE>
        
        Let's run the daemon::
        
            >>> print system('bin/logger start')
            Starting...
            <BLANKLINE>
        
        Send some data to the logger::
        
            >>> conn = Client(('localhost', 8091))
            >>> conn.send("storage1")
        
        Store file ('test') into the folder ('storage') and open a new storage::
        
            >>> conn.send(None)
        
        Send one more portion of data::
        
            >>> conn.send("storage2")
        
        Check whether the file ('test') was stored::
        
            # wait for creating file
            >>> time.sleep(1)
            >>> len(os.listdir(join(sample_buildout, 'parts/logger/storage'))) == 1
            True
        
        Stop daemon::
        
            >>> print system('bin/logger stop')
            Stopping...
            Stopped
            <BLANKLINE>
        
        
        Contributors
        ************
        
        Taras Poburynnyi (potar), Author
        
        
        Change history
        **************
        
        Changelog
        =========
        
        0.1.0b1
        -------
        
        * Initial release
        
        Download
        ********
        
Keywords: buildout logger
Platform: UNKNOWN
Classifier: Framework :: Buildout
Classifier: Framework :: Buildout :: Recipe
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
