From 98528a63ea32c6b9bb578af48b1efe65229587e9 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Tue, 23 Apr 2024 11:43:39 -0700 Subject: [PATCH] chore: clean up console upon firing up the CLI (#28134) --- UPDATING.md | 2 ++ superset/cli/main.py | 3 ++- superset/config.py | 15 ++++++++++----- superset/utils/log.py | 2 +- superset/utils/logging_configurator.py | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/UPDATING.md b/UPDATING.md index 38c40bbdd0dfa..c7e00b44e1756 100644 --- a/UPDATING.md +++ b/UPDATING.md @@ -41,6 +41,8 @@ assists people when migrating to a new version. - [27849](https://github.com/apache/superset/pull/27849/) More of an FYI, but we have a new config `SLACK_ENABLE_AVATARS` (False by default) that works in conjunction with set `SLACK_API_TOKEN` to fetch and serve Slack avatar links +- [28134](https://github.com/apache/superset/pull/28134/) The default logging level was changed + from DEBUG to INFO - which is the normal/sane default logging level for most software. ## 4.0.0 diff --git a/superset/cli/main.py b/superset/cli/main.py index d837d236d5b3f..aa7e3068f8b9d 100755 --- a/superset/cli/main.py +++ b/superset/cli/main.py @@ -37,7 +37,8 @@ ) @with_appcontext def superset() -> None: - """This is a management script for the Superset application.""" + """\033[1;37mThe Apache Superset CLI\033[0m""" + # NOTE: codes above are ANSI color codes for bold white in CLI header ^^^ @app.shell_context_processor def make_shell_context() -> dict[str, Any]: diff --git a/superset/config.py b/superset/config.py index 8e0db72b28dce..940a167bd0554 100644 --- a/superset/config.py +++ b/superset/config.py @@ -20,6 +20,7 @@ in your PYTHONPATH as there is a ``from superset_config import *`` at the end of this file. """ + # mypy: ignore-errors # pylint: disable=too-many-lines from __future__ import annotations @@ -37,6 +38,7 @@ from importlib.resources import files from typing import Any, Callable, Literal, TYPE_CHECKING, TypedDict +import click import pkg_resources from celery.schedules import crontab from flask import Blueprint @@ -274,7 +276,7 @@ def _try_json_readsha(filepath: str, length: int) -> str | None: # feature is on by default to make Superset secure by default, but you should # fine tune the limits to your needs. You can read more about the different # parameters here: https://flask-limiter.readthedocs.io/en/stable/configuration.html -RATELIMIT_ENABLED = True +RATELIMIT_ENABLED = os.environ.get("SUPERSET_ENV") == "production" RATELIMIT_APPLICATION = "50 per second" AUTH_RATE_LIMITED = True AUTH_RATE_LIMIT = "5 per second" @@ -847,7 +849,7 @@ class D3Format(TypedDict, total=False): # Console Log Settings LOG_FORMAT = "%(asctime)s:%(levelname)s:%(name)s:%(message)s" -LOG_LEVEL = "DEBUG" +LOG_LEVEL = logging.INFO # --------------------------------------------------- # Enable Time Rotate Log Handler @@ -855,7 +857,7 @@ class D3Format(TypedDict, total=False): # LOG_LEVEL = DEBUG, INFO, WARNING, ERROR, CRITICAL ENABLE_TIME_ROTATE = False -TIME_ROTATE_LOG_LEVEL = "DEBUG" +TIME_ROTATE_LOG_LEVEL = logging.INFO FILENAME = os.path.join(DATA_DIR, "superset.log") ROLLOVER = "midnight" INTERVAL = 1 @@ -1746,7 +1748,7 @@ class ExtraDynamicQueryFilters(TypedDict, total=False): if key.isupper(): setattr(module, key, getattr(override_conf, key)) - print(f"Loaded your LOCAL configuration at [{cfg_path}]") + click.secho(f"Loaded your LOCAL configuration at [{cfg_path}]", fg="cyan") except Exception: logger.exception( "Failed to import config for %s=%s", CONFIG_PATH_ENV_VAR, cfg_path @@ -1758,7 +1760,10 @@ class ExtraDynamicQueryFilters(TypedDict, total=False): import superset_config from superset_config import * # noqa: F403, F401 - print(f"Loaded your LOCAL configuration at [{superset_config.__file__}]") + click.secho( + f"Loaded your LOCAL configuration at [{superset_config.__file__}]", + fg="cyan", + ) except Exception: logger.exception("Found but failed to import local superset_config") raise diff --git a/superset/utils/log.py b/superset/utils/log.py index 0958727f983b2..cb5343470dbb7 100644 --- a/superset/utils/log.py +++ b/superset/utils/log.py @@ -321,7 +321,7 @@ def get_event_logger_from_cfg_value(cfg_value: Any) -> AbstractEventLogger: "of superset.utils.log.AbstractEventLogger." ) - logging.info("Configured event logger of type %s", type(result)) + logging.debug("Configured event logger of type %s", type(result)) return cast(AbstractEventLogger, result) diff --git a/superset/utils/logging_configurator.py b/superset/utils/logging_configurator.py index 5753b3941ccf5..ba4bf2117f728 100644 --- a/superset/utils/logging_configurator.py +++ b/superset/utils/logging_configurator.py @@ -65,4 +65,4 @@ def configure_logging( ) logging.getLogger().addHandler(handler) - logger.info("logging was configured successfully") + logger.debug("logging was configured successfully")