Skip to content

BUG: CliChannel duplicated logs, which breaks rich.Live chat box #195

@emliunix

Description

@emliunix

So this is how it looks like:

Image

Notice the duplicated log. and it breaks the UI too.

Image

RCA

new _instrument_bub breaks the logger key

https://github.com/bubbuild/bub/blob/main/src/bub/__main__.py#L12

# __main__.py
def _instrument_bub() -> None:
    from loguru import logger

    # the old 0 keyed handler removed
    logger.remove()
    # this logger gets assigned 1 as the handler key
    logger.add(sys.stderr, colorize=True)

https://github.com/bubbuild/bub/blob/main/src/bub/channels/cli/__init__.py#L53

    # channels/cli/__init__.py

    def _install_log_sink(self) -> int:
        with contextlib.suppress(ValueError):
            # this removes the handler with 0 as key, absent now, so fails, and silenced, making it really hard to spot
            # maybe we can call remove(), but then I'm afraid logfire instruments in the above code will break
            logger.remove(0)
        return logger.add(self._renderer.log, colorize=False, format="{level:<8} | {message}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions