A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: macOS logging (#2095)
Akshay Agrawalfcce36fa6148
diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.pyindex fe073e8a4b..57850ecbee 100644--- a/marimo/_cli/cli.py+++ b/marimo/_cli/cli.py@@ -169,6 +169,7 @@ def main(log_level: str, quiet: bool, development_mode: bool) -> None:GLOBAL_SETTINGS.DEVELOPMENT_MODE = development_modeGLOBAL_SETTINGS.QUIET = quiet+ GLOBAL_SETTINGS.LOG_LEVEL = _loggers.log_level_string_to_int(log_level)edit_help_msg = "\n".join(diff --git a/marimo/_config/settings.py b/marimo/_config/settings.pyindex b16bc54d91..ea72e5bcf4 100644--- a/marimo/_config/settings.py+++ b/marimo/_config/settings.py@@ -1,6 +1,7 @@# Copyright 2024 Marimo. All rights reserved.from __future__ import annotations+import loggingimport osfrom dataclasses import dataclass@@ -12,6 +13,7 @@ class GlobalSettings:CHECK_STATUS_UPDATE: bool = FalseTRACING: bool = os.getenv("MARIMO_TRACING", "false") in ("true", "1")PROFILE_DIR: str | None = None+ LOG_LEVEL: int = logging.WARNINGGLOBAL_SETTINGS = GlobalSettings()diff --git a/marimo/_loggers.py b/marimo/_loggers.pyindex 750526aae5..2622b015e3 100644--- a/marimo/_loggers.py+++ b/marimo/_loggers.py@@ -16,22 +16,28 @@ _LOG_FORMATTER = LogFormatter()_LOGGERS: dict[str, logging.Logger] = {}+def log_level_string_to_int(level: str) -> int:+ level = level.upper()+ if level == "DEBUG":+ return logging.DEBUG+ elif level == "INFO":+ return logging.INFO+ elif level == "WARN":+ return logging.WARNING+ elif level == "WARNING":+ return logging.WARNING+ elif level == "ERROR":+ return logging.ERROR+ elif level == "CRITICAL":+ return logging.CRITICAL+ else:+ raise ValueError("Unrecognized log level %s" % level)++def set_level(level: str | int = logging.WARNING) -> None:global _LOG_LEVELif isinstance(level, str):- level = level.upper()- if level == "DEBUG":- _LOG_LEVEL = logging.DEBUG- elif level == "INFO":- _LOG_LEVEL = logging.INFO- elif level == "WARN":- _LOG_LEVEL = logging.WARNING- elif level == "ERROR":- _LOG_LEVEL = logging.ERROR- elif level == "CRITICAL":- _LOG_LEVEL = logging.CRITICAL- else:- raise ValueError("Unrecognized log level %s" % level)+ _LOG_LEVEL = log_level_string_to_int(level)elif level not in [logging.DEBUG,logging.INFO,diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.pyindex e7a6ae228f..f8a70c6921 100644--- a/marimo/_runtime/runtime.py+++ b/marimo/_runtime/runtime.py@@ -1723,7 +1723,10 @@ def launch_kernel(redirect_console_to_browser: bool,interrupt_queue: QueueType[bool] | None = None,profile_path: Optional[str] = None,+ log_level: int | None = None,) -> None:+ if log_level is not None:+ _loggers.set_level(log_level)LOGGER.debug("Launching kernel")if is_edit_mode:restore_signals()diff --git a/marimo/_server/sessions.py b/marimo/_server/sessions.pyindex c54358d78d..600b12a579 100644--- a/marimo/_server/sessions.py+++ b/marimo/_server/sessions.py@@ -193,6 +193,7 @@ class KernelManager:self.redirect_console_to_browser,self.queue_manager.win32_interrupt_queue,self.profile_path,+ GLOBAL_SETTINGS.LOG_LEVEL,),# The process can't be a daemon, because daemonic processes# can't create children@@ -236,6 +237,8 @@ class KernelManager:None,# profile pathNone,+ # log level+ GLOBAL_SETTINGS.LOG_LEVEL,),# daemon threads can create child processes, unlike# daemon processesdiff --git a/marimo/_smoke_tests/tooltips.py b/marimo/_smoke_tests/tooltips.pyindex 4c984a04b1..8eb541dd28 100644--- a/marimo/_smoke_tests/tooltips.py+++ b/marimo/_smoke_tests/tooltips.py@@ -1,3 +1,4 @@+# Copyright 2024 Marimo. All rights reserved.import marimo__generated_with = "0.8.0"