Skip to content

Compatibility with IPython / prompt toolkit #1385

@GDYendell

Description

@GDYendell

Console output from loguru seems to bypass the buffering IPython does to keep its user prompt pinned to the bottom, so you get this:

In [1]: 2025-09-23 16:29:39.811 | INFO     | __main__:background_logger:13 - Log message 1
2025-09-23 16:29:40.812 | INFO     | __main__:background_logger:13 - Log message 2
2025-09-23 16:29:41.812 | INFO     | __main__:background_logger:13 - Log message 3
In [2]:

This does not happen with std logging structlog using the defaults, which uses print() to render to console. The behaviour is the same std logging.

Reproduce with:

import threading
import time

import IPython
from loguru import logger


def background_logger():
    count = 0
    while count < 3:
        time.sleep(1)
        count += 1
        logger.info(f"Log message {count}")


threading.Thread(target=background_logger, daemon=True).start()

IPython.embed()

Is there any way to make this work nicely?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement to an already existing featurequestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions