diff --git a/cognee/cli/commands/tui_command.py b/cognee/cli/commands/tui_command.py index c7136cfde..08ba54353 100644 --- a/cognee/cli/commands/tui_command.py +++ b/cognee/cli/commands/tui_command.py @@ -5,7 +5,7 @@ import cognee.cli.echo as fmt from cognee.cli.exceptions import CliCommandException from cognee.cli.tui.home_screen import HomeScreen from textual.app import App - +from cognee.shared.logging_utils import setup_logging class TuiCommand(SupportsCliCommand): @@ -40,9 +40,9 @@ class TuiCommand(SupportsCliCommand): """Push the home screen on mount.""" self.push_screen(HomeScreen()) + setup_logging(enable_console_logging=False) app = CogneeTUI() app.run() - fmt.success("TUI exited successfully!") except ImportError: raise CliCommandException( "Textual is not installed. Install with: pip install textual", diff --git a/cognee/shared/logging_utils.py b/cognee/shared/logging_utils.py index e8efde72c..2fdbe1cbb 100644 --- a/cognee/shared/logging_utils.py +++ b/cognee/shared/logging_utils.py @@ -285,7 +285,7 @@ def cleanup_old_logs(logs_dir, max_files): return False -def setup_logging(log_level=None, name=None): +def setup_logging(log_level=None, name=None, enable_console_logging=True): """Sets up the logging configuration with structlog integration. Args: @@ -465,7 +465,8 @@ def setup_logging(log_level=None, name=None): root_logger = logging.getLogger() if root_logger.hasHandlers(): root_logger.handlers.clear() - root_logger.addHandler(stream_handler) + if enable_console_logging: + root_logger.addHandler(stream_handler) # Note: root logger needs to be set at NOTSET to allow all messages through and specific stream and file handlers # can define their own levels.