Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install collective.recipe.logger

How to install collective.recipe.logger

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install collective.recipe.logger
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
Linux (64-bit)
0.1.0b1 Available View build log
 
License
GPL
Lastest release
version 0.1.0b1 on Jan 9th, 2014
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'.
    

Let's test the daemon::

    >>> print system('bin/logger start')
    Starting...
    

    >>> 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
    

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'.
    

Let's run the daemon::

    >>> print system('bin/logger start')
    Starting...
    

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
    


Contributors
************

Taras Poburynnyi (potar), Author


Change history
**************

Changelog
=========

0.1.0b1
-------

* Initial release

Download
********

Subscribe to package updates

Last updated Jan 9th, 2014

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.