def METHOD_NAME(app: Flask, custom_path_to_config: str | None):
    """Read configuration from various expected sources, complain if not setup correctly."""
    check_app_env(app.env)
    # First, load default config settings
    app.config.from_object(
        "flexmeasures.utils.config_defaults.%sConfig" % camelize(app.env)
    )
    # Now, potentially overwrite those from config file or environment variables
    # These two locations are possible (besides the custom path)
    path_to_config_home = str(Path.home().joinpath(".flexmeasures.cfg"))
    path_to_config_instance = os.path.join(app.instance_path, "flexmeasures.cfg")
    # Custom config: do not use any when testing (that should run completely on defaults)
    if not app.testing:
        used_path_to_config = read_custom_config(
            app, custom_path_to_config, path_to_config_home, path_to_config_instance
        )
        read_env_vars(app)
    else:  # one exception: the ability to set where the test database is
        custom_test_db_uri = os.getenv("SQLALCHEMY_TEST_DATABASE_URI", None)
        if custom_test_db_uri:
            app.config["SQLALCHEMY_DATABASE_URI"] = custom_test_db_uri
    # Check for missing values.
    # Documentation runs fine without them.
    if not app.testing and app.env != "documentation":
        if not are_required_settings_complete(app):
            if not os.path.exists(used_path_to_config):
                print(
                    f"You can provide these settings ― as environment variables or in your config file (e.g. {path_to_config_home} or {path_to_config_instance})."
                )
            else:
                print(
                    f"Please provide these settings ― as environment variables or in your config file ({used_path_to_config})."
                )
            sys.exit(2)
        missing_fields, config_warnings = get_config_warnings(app)
        if len(config_warnings) > 0:
            for warning in config_warnings:
                print(f"Warning: {warning}")
            print(f"You might consider setting {', '.join(missing_fields)}.")
    # Set the desired logging level on the root logger (controlling extension logging level)
    # and this app's logger.
    logging.getLogger().setLevel(app.config.get("LOGGING_LEVEL", "INFO"))
    app.logger.setLevel(app.config.get("LOGGING_LEVEL", "INFO"))
    # print("Logging level is %s" % logging.getLevelName(app.logger.level))
    app.config["START_TIME"] = datetime.utcnow()