Metadata-Version: 1.2
Name: logsense-logger
Version: 0.0.1
Summary: A Python logging handler for sending logs to LogSense
Home-page: https://github.com/collectivesense/logsense-logger-python
License: Apache License, Version 2.0
Download-URL: http://pypi.python.org/pypi/logsense-logger/
Description: # logsense-logger-python
        
        Provides a set of wrapper classes and method for working
        with Python and [LogSense](https://logsense.com)
        
        # Usage
        
        ## Installation
        
        ```
        pip3 install -e git+https://github.com/collectivesense/logsense-logger-python#egg=logsense-logger
        ```
        
        
        ## Wrapping logging
        
        ```
        from logsense.handler import LogSenseHandler
        from os import getenv
        import logging
        
        logsense_token = getenv('LOGSENSE_TOKEN', None)
        logging.getLogger().addHandler(LogSenseHandler(logsense_token))
        
        
        class Example:
            def __init__(self):
                self.bar = 42
        
            def foo(self):
                logging.info("Answer: {}".format(self.bar))
        
        
        if __name__ == "__main__":
            ex = Example()
            ex.foo()
        ```
        
        Now, just run the app, e.g.
        
        ```
        LOGSENSE_TOKEN="63da4903-01e9-d1a4-82a8-9cf8cd63b7b5" python sample_logging.py
        ```
        
        And your logs should flow to LogSense
        
        ## Metrics
        
        The package also includes a simple example on how to measure method duration
        and have ability to track metrics. All that needs to be done is providing
        `LOGSENSE_TOKEN` environment variable and than annotating
        methods that are to be measure with `@measure_duration()`. For example:
        
        ```
        from logsense.metrics import measure_duration, setup_metrics
        from os import getenv
        
        logsense_token = getenv('LOGSENSE_TOKEN')
        setup_metrics('myapp', logsense_token)
        
        
        class MyComplexProcess:
            def __init__(self, how_many_times):
                self._how_many_times = how_many_times
        
            @measure_duration(extracted_params=['a'])
            def foo(self, a):
                x = 0
                for i in range(a*self._how_many_times):
                    x = x+1
                return x
        ```
        
        ## Examples
        
        Check the [example](example/) for actual usage examples
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Development Status :: 5 - Production/Stable
Classifier: Topic :: System :: Logging
Classifier: Intended Audience :: Developers
Requires-Python: >=2.7,!=3.0,!=3.1,!=3.2,!=3.3,<3.8
