Metadata-Version: 1.0
Name: siftlog
Version: 0.11
Summary: Structured JSON logging
Home-page: http://github.com/papito/siftlog-py
Author: Andrei Taranchenko
Author-email: andrei360-git@yahoo.com
License: MIT
Description: Sift Log - JSON logging adapter for Python
        ==========================================
        
        Features
        --------
        
        -  Tag log statements with arbitrary values for easier grouping and
           analysis
        -  Add arbitrary keyword arguments that are converted to JSON values
        -  Variable substitution in log messages
        -  ``TRACE`` log level built-in
        -  Meant to be used with core Python logging (formatters, handlers, etc)
        
        Examples
        --------
        
        A simple log message
        ^^^^^^^^^^^^^^^^^^^^
        
        .. code:: python
        
            log.info('Hello')
        
        ``{"msg": "Hello", "time": "12-12-14 10:12:01 EST", "level": "INFO", "loc": "test:log_test:20"}``
        
        Logging with tags
        ^^^^^^^^^^^^^^^^^
        
        .. code:: python
        
            log.debug('Creating new user', 'MONGO', 'STORAGE')
        
        ``{"msg": "Creating new user", "time": "12-12-14 10:12:09 EST", "tags": ["tag.MONGO", "tag.STORAGE"], "level": "DEBUG", "loc": "test:log_test:20"}``
        
        Adding JSON keys
        ^^^^^^^^^^^^^^^^
        
        .. code:: python
        
            log.debug('Some key', is_admin = True, username = 'papito')
        
        ``{"msg": "Some key", "is_admin": true, "username": "papito", "time": "12-12-14 10:12:04 EST", "level": "DEBUG", "loc": "test:log_test:20"}``
        
        String substitution
        ^^^^^^^^^^^^^^^^^^^
        
        .. code:: python
        
            log.debug('User "$username" admin? $is_admin', is_admin = False, username = 'fez')
        
        ``{"msg": "User \"fez\" admin? False",  "username": "fez", "is_admin": false, "time": "12-12-14 10:12:18 EST", "level": "DEBUG", "loc": "test:log_test:20"}``
        
        Setup
        -----
        
        Logging to console
        ^^^^^^^^^^^^^^^^^^
        
        .. code:: python
        
            import sys
            import logging
            from siftlog import SiftLog
        
            logger = logging.getLogger()
            logger.setLevel(logging.INFO)
            handler = logging.StreamHandler(sys.stdout)
            logger.addHandler(handler)
        
            log = SiftLog(logger)
        
        In this fashion, you can direct the JSON logs to `any core logging
        handler <https://docs.python.org/2/library/logging.handlers.html>`__
        
        Constants (re-occuring values)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        
        You can define constants that will appear in every single log message.
        This is useful, for example, if you'd like to log process PID and
        hostname with every log message (recommended). This is done upon log
        adapter initialization:
        
        .. code:: python
        
            import os
            from siftlog import SyftLog
            log = SiftLog(logger, pid = os.getpid(), env='INTEGRATION')
        
        ``{"msg": "And here I am", "time": "12-12-14 11:12:24 EST", "pid": 37463, "env": "INTEGRATION", "level": "INFO"}``
        
        Custom time format
        ^^^^^^^^^^^^^^^^^^
        
        Define ``SiftLog.TIME_FORMAT``, accepted by
        `time.strftime() <https://docs.python.org/2/library/time.html#time.strftime>`__
        
        Custom core key names
        ^^^^^^^^^^^^^^^^^^^^^
        
        Key names, such as ``msg`` and ``level`` can be overridden, if they
        clash with common keys you might be using.
        
        The following can be redefined:
        
        -  **SiftLog.MESSAGE** (default ``msg``)
        -  **SiftLog.LEVEL** (default ``level``)
        -  **SiftLog.LOCATION** (default ``loc``)
        -  **SiftLog.TAGS** (default ``tags``)
        -  **SiftLog.TIME** (default ``time``)
        
        Tag prefix
        ^^^^^^^^^^
        
        Arbitrary tags by default are prefixed with ``tag.``, for easier
        searching. The prefix can be changed, or removed, by redefining
        ``SiftLog.TAG_PREFIX``
        
Platform: UNKNOWN
