python-devtools icon indicating copy to clipboard operation
python-devtools copied to clipboard

Add option to change print function

Open barabum0 opened this issue 1 year ago • 4 comments

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

barabum0 avatar Oct 29 '23 16:10 barabum0