Is there a way to incorporate Icecream as a default output function?
I've seen this issue #541 but since it's quite old was wondering if there is a newer way to use Icecream pretty output?
My logger.debug() mode dumps quite a lot of dictionarys, lists, json strings and objects and it would be much much nice to read it in a structured way.
Thanks.
my intuition is with the availability of ic.format() it will be quite straightforward to wrap the 2?
or is there sophisticated usage of either tool required in your usecase that necessitates a low-level merge?
Hi.
I don't know if this exactly meets your needs, but note that I plan to extend the logging functions so that keyword arguments are automatically logged.
logger.debug("Message", foo=123)
# Planned output: 2025-07-27 18:03:17.115 +02:00 | DEBUG | __main__:<module>:4 - Message (foo=123)
However, this has not yet been implemented, and it'll be less advanced formatting that the one provided by icecream.
As suggested by @jkpjkpjkp, I think the simplest solution is just to use ic.format() like so:
from icecream import ic
from loguru import logger
def foo(i):
return i + 333
logger.debug("Message: {}", ic.format(foo(123)))
The icecream library is doing some introspection magic to produce foo(123): 456 output and I don't think it can be integrated otherwise with Loguru.