redis/redis-vl-python

RedisVL breaks existing logging configurations

Closed this issue ยท 3 comments

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 ๐Ÿ™

Thanks for reporting this! We are working on a fix/improvement. Definitely frustrating.

@duc00 we've merged this into our 0.5.0 release branched slated to go out in the next week. Thanks for reporting this!

@tylerhutcherson great! Thanks