samuelcolvin / python-devtools

Dev tools for python
https://python-devtools.helpmanual.io/
MIT License
985 stars 47 forks source link

Add option to change print function #145

Open barabum0 opened 1 year ago

barabum0 commented 1 year ago

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
codecov[bot] commented 1 year ago

Codecov Report

Merging #145 (fb8c506) into main (ec406ff) will decrease coverage by 0.26%. The diff coverage is 60.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #145 +/- ## ========================================== - Coverage 96.29% 96.03% -0.26% ========================================== Files 8 8 Lines 729 732 +3 Branches 111 112 +1 ========================================== + Hits 702 703 +1 - Misses 21 22 +1 - Partials 6 7 +1 ``` | [Files](https://app.codecov.io/gh/samuelcolvin/python-devtools/pull/145?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin) | Coverage Δ | | |---|---|---| | [devtools/debug.py](https://app.codecov.io/gh/samuelcolvin/python-devtools/pull/145?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin#diff-ZGV2dG9vbHMvZGVidWcucHk=) | `98.48% <60.00%> (-1.52%)` | :arrow_down: | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/samuelcolvin/python-devtools/pull/145?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/samuelcolvin/python-devtools/pull/145?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin). Last update [ec406ff...fb8c506](https://app.codecov.io/gh/samuelcolvin/python-devtools/pull/145?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Samuel+Colvin).
barabum0 commented 1 year ago

added some commits to please lint checker

barabum0 commented 1 year ago

CI / lint (pull_request) Failing after 1m

I actually don't know whats wrong with my code (if so). But my feature is working correctly, so please review and merge it

maltevesper commented 11 months ago

CI / lint (pull_request) Failing after 1m

I actually don't know whats wrong with my code (if so). But my feature is working correctly, so please review and merge it

While I am not involved with the project, you might be able to fix your issue: apparently you overindented something, try reformatting with black and committing. You can see the ci issue here: https://github.com/samuelcolvin/python-devtools/actions/runs/6684613574/job/18162063139?pr=145#step:6:158