Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need of ic.debug(**kwargs), ic.info(**kwargs) like methods to lib to increase production usage #188

Open
UlucFVardar opened this issue Sep 20, 2024 · 2 comments

Comments

@UlucFVardar
Copy link

ic is a great library,
but I think it has one shortcoming.

When using it in a big project, it becomes critical to perform the print operation according to the logging level.

In my current codes, there is always a code add-on like the one below.

if os.environ.get('LOGGING_LEVEL', 'INFO') == 'DEBUG':
    ic(MY_VALUE)

This is a big need to be added to the library!

from icecream import ic
ic.debug()
ic.info()
ic.warning()
ic()

OR

from icecream import ic_error
from icecream import ic_warning
from icecream import ic_debug
from icecream import ic_info
from icecream import ic
ic_debug()
ic_info()
ic_warning()
ic()

Using it like this will be very useful in projects.

Also, if the colors printed according to the logging level are changed, we will have a much more understandable print style.

@salabim
Copy link

salabim commented Sep 20, 2024

You can do all this with an alternative package, called ycecream (www.github.com/salabim/ycecream).

@Xaelias
Copy link

Xaelias commented Oct 16, 2024

You can define multiple instances of ic with their own output method to address this.

Smth like:

from icecream import IceCreamDebugger

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

def error(input: str):
    logger.error(input)


def debug(input: str):
    logger.debug(input)


icd = IceCreamDebugger(outputFunction=debug)
ice = IceCreamDebugger(outputFunction=error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants