Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Simplify record name

Magnus Müller5530e2485e60
diff --git a/browser_use/config.py b/browser_use/config.py
index cafe27bd2..82ad3b60e 100644
--- a/browser_use/config.py
+++ b/browser_use/config.py
@@ -180,7 +180,7 @@ class FlatEnvConfig(BaseSettings):
# Logging and telemetry
BROWSER_USE_LOGGING_LEVEL: str = Field(default='info')
- CDP_LOGGING_LEVEL: str = Field(default='warning')
+ CDP_LOGGING_LEVEL: str = Field(default='error')
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.py
index e4c41225f..8bef6855b 100644
--- a/browser_use/logging_config.py
+++ b/browser_use/logging_config.py
@@ -86,32 +86,50 @@ def setup_logging(stream=None, log_level=None, force_setup=False):
root.handlers = []
class BrowserUseFormatter(logging.Formatter):
+ def __init__(self, fmt, log_level):
+ super().__init__(fmt)
+ self.log_level = log_level
+
def format(self, record):
- # if isinstance(record.name, str) and record.name.startswith('browser_use.'):
- # record.name = record.name.split('.')[-2]
+ # Only clean up names in INFO mode, keep everything in DEBUG mode
+ if self.log_level > logging.DEBUG and isinstance(record.name, str) and record.name.startswith('browser_use.'):
+ # Extract clean component names from logger names
+ if 'Agent🅰' in record.name:
+ record.name = 'Agent'
+ elif 'BrowserSession🆂' in record.name:
+ record.name = 'BrowserSession'
+ elif 'controller' in record.name:
+ record.name = 'controller'
+ elif 'dom' in record.name:
+ record.name = 'dom'
+ elif record.name.startswith('browser_use.'):
+ # For other browser_use modules, use the last part
+ parts = record.name.split('.')
+ if len(parts) >= 2:
+ record.name = parts[-1]
return super().format(record)
# Setup single handler for all loggers
console = logging.StreamHandler(stream or sys.stdout)
+ # Determine the log level to use first
+ if log_type == 'result':
+ log_level = 35 # RESULT level value
+ elif log_type == 'debug':
+ log_level = logging.DEBUG
+ else:
+ log_level = logging.INFO
+
# adittional setLevel here to filter logs
if log_type == 'result':
console.setLevel('RESULT')
- console.setFormatter(BrowserUseFormatter('%(message)s'))
+ console.setFormatter(BrowserUseFormatter('%(message)s', log_level))
else:
- console.setFormatter(BrowserUseFormatter('%(levelname)-8s [%(name)s] %(message)s'))
+ console.setFormatter(BrowserUseFormatter('%(levelname)-8s [%(name)s] %(message)s', log_level))
# Configure root logger only
root.addHandler(console)
- # Determine the log level to use
- if log_type == 'result':
- log_level = 35 # RESULT level value
- elif log_type == 'debug':
- log_level = logging.DEBUG
- else:
- log_level = logging.INFO
-
# Configure root logger
root.setLevel(log_level)
@@ -142,7 +160,7 @@ def setup_logging(stream=None, log_level=None, force_setup=False):
elif cdp_log_type == 'error':
cdp_log_level = logging.ERROR
else:
- cdp_log_level = logging.WARNING # Default to WARNING
+ cdp_log_level = logging.ERROR # Default to WARNING
try:
from cdp_use.logging import setup_cdp_logging # type: ignore