Skip to main content

Python debug logging helpers

Project description

debug_this

Package Status Documentation Status License Status Build Status Quality Status

Python debug logging helpers

@debug_this.fucking_function

This decorator can be used to log the execution of an unfriendly function.

import logging
import debug_this

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

@debug_this.fucking_function(logger)
def example_function():
    logger.info("This is an example function")

example_function()

The resulting logs should look like this:

DEBUG:__main__:  >>> example_function
INFO:__main__:This is an example function
DEBUG:__main__:  <<< example_function

@debug_this.fucking_class

This decorator can be used to log the execution of an unfriendly class.

import logging
import debug_this

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

@debug_this.fucking_class(logger)
class ExampleClass:
    def __init__(self):
        logger.info("Example constructor")

    def example_method(self):
        logger.info("Example method")

e = ExampleClass()
e.example_method()

The resulting logs should look like this:

DEBUG:__main__:  >>> ExampleClass.__init__
INFO:__main__:Example constructor
DEBUG:__main__:  <<< ExampleClass.__init__
DEBUG:__main__:  >>> ExampleClass.example_method
INFO:__main__:Example method
DEBUG:__main__:  <<< ExampleClass.example_method

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

debug_this-0.3.0.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

debug_this-0.3.0-py3-none-any.whl (2.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page