Hi, I’m currently using this to log my python process

logging.basicConfig(filename='filename.log', level=logging.DEBUG)

logger = logging.getLogger()

sys.stderr.write = logger.error

sys.stdout.write = logger.info

And then using print(f’{datetime.now()} log message’) where I want to log.

It’s working OK, buy I would like to live it to ic, but can’t find any info on how to send the ic output to the logger.

Thanks for any help.

  • sloppy_diffuser@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    0
    ·
    3 months ago

    Never used ic before, but there is an example in the README on GitHub.

    >>> import logging
    >>> from icecream import ic
    >>>
    >>> def warn(s):
    >>>     logging.warning(s)
    >>>
    >>> ic.configureOutput(outputFunction=warn)
    >>> ic('eep')
    WARNING:root:ic| 'eep': 'eep'