Metadata-Version: 1.1
Name: logaugment
Version: 0.1
Summary: Python logging library for augmenting log records with additional information
Home-page: https://github.com/svisser/logaugment
Author: Simeon Visser
Author-email: simeonvisser@gmail.com
License: MIT
Description: logaugment
        ==========
        
        Python logging library for augmenting log records with additional information.
        
        This library supports Python 2.7+.
        
        If you want custom keys in your logged string:
        
        .. code:: python
        
            formatter = logging.Formatter("%(message)s: %(custom_key)s")
        
        then this library allows you to add them easily:
        
        .. code:: python
        
            logaugment.add(logger, custom_key='custom_value')
            logger.warn("My message")
            # My message: custom_value
        
        Why?
        ====
        
        If you need to add custom keys to your Python logging strings you need to pass
        them in with each logging call. That is inconvenient so this library allows you
        to add values just once and they're then available for all logging calls
        afterwards.
        
        Here is a full example:
        
        .. code:: python
        
            import logging
            import logaugment
            logger = logging.getLogger()
            handler = logging.StreamHandler()
            formatter = logging.Formatter("%(message)s: %(custom_key)s")
            handler.setFormatter(formatter)
            logger.addHandler(handler)
        
            logaugment.add(logger, custom_key='custom_value')
            logger.warn("My message")
            # My message: custom_value
        
        Examples
        ========
        
        You can use keywords to specify additional values:
        
        .. code:: python
        
            logaugment.add(logger, custom_key='custom_value')
            logger.warn("My message")
            # My message: custom_value
        
        You can also use a dictionary to specify the keys / values:
        
        .. code:: python
        
            logaugment.add(logger, {'custom_key': 'custom_value'})
            logger.warn("My message")
            # My message: custom_value
        
        You can also use a function which returns a dictionary:
        
        .. code:: python
        
            logaugment.add(logger, lambda record: {'custom_key': record.levelname})
            logger.warn("My message")
            # My message: WARNING
        
        You can pass an `extra` dictionary in the call which overrides the
        augmented data:
        
        .. code:: python
        
            logaugment.add(logger, {'custom_key': 'custom_value'})
            logger.warn("My message", extra={'custom_key': 'extra_value'})
            # My message: extra_value
        
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.1
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: System :: Logging
