Python debug logging helpers
Project description
debug_this
Python debug logging helpers
Installation
Using pip
:
pip install debug_this
Usage
The debug_this
module export some decorators that can be used to debug your
fucking code:
@debug_this.fucking_function
To be used on those fucking functions that do not want to work as expected.@debug_this.fucking_class
To be used on fucking classes that are... Well you know!
All these decorators can be used with or without arguments or keywords arguments.
The available arguments are:
logger
(logging.Logger
, optional) Specify a logger instead of the default one.print_parent
(bool
, optional) Print which function has called the decorated function.
Example
from __future__ import annotations
import logging
import debug_this
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
@debug_this.fucking_function(print_parent=True)
def example_function() -> None:
logger.info("This is an example function")
@debug_this.fucking_class(logger)
class ExampleClass:
def __init__(self) -> None:
logger.info("This is an example class constructor")
ExampleClass.example_static_method(self)
def example_method(self) -> None:
logger.info("This is an example class method")
example_function()
@staticmethod
def example_static_method(cls: ExampleClass) -> None:
logger.info("This is an example class static method")
cls.example_method()
if __name__ == "__main__":
ExampleClass()
The resulting logs should look like this:
DEBUG:__main__: >>> ExampleClass.__init__
INFO:__main__:This is an example class constructor
DEBUG:__main__: >>> ExampleClass.example_static_method
INFO:__main__:This is an example class static method
DEBUG:__main__: >>> ExampleClass.example_method
INFO:__main__:This is an example class method
DEBUG:debug_this: >>> example_function (parent: example_method)
INFO:__main__:This is an example function
DEBUG:debug_this: <<< example_function
DEBUG:__main__: <<< ExampleClass.example_method
DEBUG:__main__: <<< ExampleClass.example_static_method
DEBUG:__main__: <<< ExampleClass.__init__
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-1.0.0.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for debug_this-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5659fe87aaf1057972393c2b6065650f6007b3a74e1332139cdc48cb8f2129be |
|
MD5 | 032e754aaec4e6c1b3741ced595590e5 |
|
BLAKE2b-256 | 5f2c3c07892d02eb0b07eafbd3eebe57e2f1cf40fce7e10670319112f582a0eb |