Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Enhance logging configuration with CDP logging level and environment settings
Cursor Agent2f3a19bf7e61
diff --git a/.env.example b/.env.exampleindex 4ee070e6b..3fe667fd6 100644--- a/.env.example+++ b/.env.example@@ -1,20 +1,64 @@+# Browser Use Environment Configuration+# Copy this file to .env and configure your API keys and settings++# =============================================================================+# API Keys for Language Models+# =============================================================================OPENAI_API_KEY=ANTHROPIC_API_KEY=-AZURE_OPENAI_ENDPOINT=-AZURE_OPENAI_API_KEY=GOOGLE_API_KEY=DEEPSEEK_API_KEY=GROK_API_KEY=NOVITA_API_KEY=-# Set to false to disable anonymized telemetry-ANONYMIZED_TELEMETRY=true+# Azure OpenAI Configuration+AZURE_OPENAI_ENDPOINT=+AZURE_OPENAI_KEY=-# LogLevel: Set to debug to enable verbose logging, set to result to get results only. Available: result | debug | info+# =============================================================================+# Logging Configuration+# =============================================================================+# Browser Use logging level (debug, info, warning, error)BROWSER_USE_LOGGING_LEVEL=info-# Calculate costs: (beta) Add cost calculations to tokens. Available: true | false-BROWSER_USE_CALCULATE_COST=false+# CDP (Chrome DevTools Protocol) logging level for cdp_use library+# Controls logging verbosity of Chrome DevTools Protocol interactions+# Recommended: WARNING to reduce noise (debug, info, warning, error)+CDP_LOGGING_LEVEL=WARNING++# =============================================================================+# Telemetry and Cloud Configuration+# =============================================================================+# Enable anonymous telemetry collection+ANONYMIZED_TELEMETRY=true++# Browser Use Cloud Configuration+BROWSER_USE_CLOUD_SYNC=+BROWSER_USE_CLOUD_API_URL=https://api.browser-use.com+BROWSER_USE_CLOUD_UI_URL=++# =============================================================================+# Development and Runtime Configuration+# =============================================================================+# Skip LLM API key verification during initialization+SKIP_LLM_API_KEY_VERIFICATION=false++# Runtime environment flags+IN_DOCKER=+IS_IN_EVALS=false++# Path configuration+XDG_CACHE_HOME=~/.cache+XDG_CONFIG_HOME=~/.config+BROWSER_USE_CONFIG_DIR=++# Windows font directory (Windows only)+WIN_FONT_DIR=C:\Windows\Fonts-# set this to true to optimize browser-use's chrome for running inside docker-IN_DOCKER=false+# =============================================================================+# MCP (Model Context Protocol) Configuration+# =============================================================================+BROWSER_USE_CONFIG_PATH=+BROWSER_USE_HEADLESS=+BROWSER_USE_ALLOWED_DOMAINS=+BROWSER_USE_LLM_MODEL=diff --git a/browser_use/config.py b/browser_use/config.pyindex 9b1b91446..6c78ea98f 100644--- a/browser_use/config.py+++ b/browser_use/config.py@@ -180,6 +180,7 @@ class FlatEnvConfig(BaseSettings):# Logging and telemetryBROWSER_USE_LOGGING_LEVEL: str = Field(default='info')+ CDP_LOGGING_LEVEL: str = Field(default='WARNING')ANONYMIZED_TELEMETRY: bool = Field(default=True)BROWSER_USE_CLOUD_SYNC: bool | None = Field(default=None)BROWSER_USE_CLOUD_API_URL: str = Field(default='https://api.browser-use.com')diff --git a/browser_use/logging_config.py b/browser_use/logging_config.pyindex 9f852160a..db27324d2 100644--- a/browser_use/logging_config.py+++ b/browser_use/logging_config.py@@ -128,13 +128,17 @@ def setup_logging(stream=None, log_level=None, force_setup=False):bubus_logger.setLevel(logging.INFO if log_type == 'result' else log_level)# Configure CDP logging using cdp_use's setup function- # This enables the formatted CDP output at the same level as browser_use+ # This enables the formatted CDP output using CDP_LOGGING_LEVEL environment variable+ # Convert CDP_LOGGING_LEVEL string to logging level+ cdp_level_str = CONFIG.CDP_LOGGING_LEVEL.upper()+ cdp_level = getattr(logging, cdp_level_str, logging.WARNING)+try:from cdp_use.logging import setup_cdp_logging # type: ignore- # Use the same stream and level as browser_use+ # Use the CDP-specific logging levelsetup_cdp_logging(- level=log_level,+ level=cdp_level,stream=stream or sys.stdout,format_string='%(levelname)-8s [%(name)s] %(message)s' if log_type != 'result' else '%(message)s',)@@ -149,7 +153,7 @@ def setup_logging(stream=None, log_level=None, force_setup=False):]for logger_name in cdp_loggers:cdp_logger = logging.getLogger(logger_name)- cdp_logger.setLevel(log_level)+ cdp_logger.setLevel(cdp_level)cdp_logger.addHandler(console)cdp_logger.propagate = False