python-devtools
python-devtools copied to clipboard
Add option to change print function
I added logger_function parameter to Debug() class that replaces print if set. Here is an example of usage with loguru:
from devtools import Debug
from loguru import logger
debug = Debug(logger_function=logger.debug)
test_object = {
"string": "test",
"integer": 123,
"nested": {
"key": "value"
}
}
debug(test_object)
# 2023-10-29 18:38:45.211 | DEBUG | devtools.debug:__call__:127 - logger_func_test.py:13 <module>
# test_object: {
# 'string': 'test',
# 'integer': 123,
# 'nested': {
# 'key': 'value',
# },
# } (dict) len=3