diff --git a/codewiki/cli/adapters/doc_generator.py b/codewiki/cli/adapters/doc_generator.py index b2e95368..ff93642a 100644 --- a/codewiki/cli/adapters/doc_generator.py +++ b/codewiki/cli/adapters/doc_generator.py @@ -13,12 +13,6 @@ import logging import sys -# Suppress verbose third-party library logs (OpenAI, Anthropic, httpx) -logging.getLogger("httpx").setLevel(logging.WARNING) -logging.getLogger("openai").setLevel(logging.WARNING) -logging.getLogger("openai._base_client").setLevel(logging.WARNING) -logging.getLogger("anthropic").setLevel(logging.WARNING) - from codewiki.cli.utils.progress import ProgressTracker from codewiki.cli.models.job import DocumentationJob, LLMConfig from codewiki.cli.utils.errors import APIError diff --git a/codewiki/cli/commands/generate.py b/codewiki/cli/commands/generate.py index 2cf8e573..ba469ae7 100644 --- a/codewiki/cli/commands/generate.py +++ b/codewiki/cli/commands/generate.py @@ -216,12 +216,6 @@ def generate_command( logger = create_logger(verbose=verbose) start_time = time.time() - # Suppress verbose third-party library logs - logging.getLogger("httpx").setLevel(logging.WARNING) - logging.getLogger("openai").setLevel(logging.WARNING) - logging.getLogger("openai._base_client").setLevel(logging.WARNING) - logging.getLogger("anthropic").setLevel(logging.WARNING) - try: # Pre-generation checks logger.step("Validating configuration...", 1, 4) @@ -553,3 +547,4 @@ def generate_command( except Exception as e: sys.exit(handle_error(e, verbose=verbose)) + diff --git a/codewiki/cli/utils/logging.py b/codewiki/cli/utils/logging.py index 80863404..c882407f 100644 --- a/codewiki/cli/utils/logging.py +++ b/codewiki/cli/utils/logging.py @@ -2,6 +2,7 @@ Logging utilities for CLI with colored output and progress tracking. """ +import logging import sys from datetime import datetime from typing import Optional @@ -71,6 +72,26 @@ def elapsed_time(self) -> str: return f"{seconds}s" +# Third-party HTTP/SDK loggers emit one INFO line per request. Across a +# documentation run that is thousands of lines of noise in CI, so they are +# capped at WARNING. Applied from create_logger() rather than at import time: +# a setLevel() side effect that fires merely because a module was imported is +# invisible to anyone reading the call site, and fires even for importers that +# never wanted it. +_NOISY_THIRD_PARTY_LOGGERS = ( + "httpx", + "openai", + "openai._base_client", + "anthropic", +) + + +def quiet_third_party_loggers(level: int = logging.WARNING) -> None: + """Cap the noisiest third-party loggers so CLI output stays readable.""" + for name in _NOISY_THIRD_PARTY_LOGGERS: + logging.getLogger(name).setLevel(level) + + def create_logger(verbose: bool = False) -> CLILogger: """ Create and return a CLI logger. @@ -81,5 +102,6 @@ def create_logger(verbose: bool = False) -> CLILogger: Returns: Configured CLILogger instance """ + quiet_third_party_loggers() return CLILogger(verbose=verbose)