Skip to content

RedisVL breaks existing logging configurations #293

@duc00

Description

@duc00

Hi,

Thank you for this very helpful repo. Redis has always been and is still total 🔥.

Simply importing some structures from RedisVL breaks existing logging configurations, because they get overridden by the following function call:

coloredlogs.install(level=log_level, logger=logger, fmt=fmt, stream=sys.stdout)

Here is a simple reproducer:

import logging
import sys

handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(
    logging.Formatter(
        "%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)s] %(message)s"
    )
)

root_logger = logging.getLogger()
root_logger.handlers = [handler]
root_logger.setLevel(logging.INFO)

my_logger = logging.getLogger("app")
my_logger.info("This is correctly formatted")

from redisvl.query.filter import Text

my_logger.info("This is NOT correctly formatted and has been overridden by RedisVL")

Output:

➜  redisvl-issue-log poetry run python redisvl_issue_log/repro.py
2025-02-28 18:18:24,036 INFO [app] [repro.py:16] This is correctly formatted
18:18:24 app INFO   This is NOT correctly formatted and has been overridden by RedisVL

This is a very frustrating issue, since it is happening silently at the first RedisVL import. I spent a few hours pinning to this repository. I believe many could have encountered such issues trying to configure general logging, and gave up figuring it out.

Could we disable coloredlogs or at least make sure importing objects outside of CLI does not trigger its installation on the root logger?

Many thanks 🙏

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