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
fix unbound logger
Nick Sweetingeb2807e77962
diff --git a/browser_use/utils.py b/browser_use/utils.pyindex b4a81e8c5..21fcb7821 100644--- a/browser_use/utils.py+++ b/browser_use/utils.py@@ -313,13 +313,15 @@ def time_execution_sync(additional_text: str = '') -> Callable[[Callable[P, R]],execution_time = time.time() - start_time# Only log if execution takes more than 0.25 secondsif execution_time > 0.25:- if args and getattr(args[0], 'logger', None):+ self_has_logger = args and getattr(args[0], 'logger', None)+ if self_has_logger:logger = args[0].logger- if 'agent' in kwargs:+ elif 'agent' in kwargs:logger = kwargs['agent'].loggerelif 'browser_session' in kwargs:logger = kwargs['browser_session'].logger-+ else:+ logger = logging.getLogger(__name__)logger.debug(f'⏳ {additional_text.strip("-")}() took {execution_time:.2f}s')return result@@ -340,12 +342,15 @@ def time_execution_async(# Only log if execution takes more than 0.25 seconds to avoid spamming the logs# you can lower this threshold locally when you're doing dev work to performance optimize stuffif execution_time > 0.25:- if args and getattr(args[0], 'logger', None):+ self_has_logger = args and getattr(args[0], 'logger', None)+ if self_has_logger:logger = args[0].logger- if 'agent' in kwargs:+ elif 'agent' in kwargs:logger = kwargs['agent'].loggerelif 'browser_session' in kwargs:logger = kwargs['browser_session'].logger+ else:+ logger = logging.getLogger(__name__)logger.debug(f'⏳ {additional_text.strip("-")}() took {execution_time:.2f}s')return result