diff --git a/.changes/unreleased/added-20260205-163010.yaml b/.changes/unreleased/added-20260205-163010.yaml new file mode 100644 index 00000000..be9f934d --- /dev/null +++ b/.changes/unreleased/added-20260205-163010.yaml @@ -0,0 +1,8 @@ +kind: added +body: Change header print messages to info log +time: 2026-02-05T16:30:10.310834+02:00 +custom: + Author: mwc360 + AuthorLink: https://github.com/mwc360 + Issue: "771" + IssueLink: https://github.com/microsoft/fabric-cicd/issues/771 diff --git a/src/fabric_cicd/_common/_logging.py b/src/fabric_cicd/_common/_logging.py index 043b50c1..428e1b60 100644 --- a/src/fabric_cicd/_common/_logging.py +++ b/src/fabric_cicd/_common/_logging.py @@ -136,19 +136,20 @@ def exception_handler(exception_type: type[BaseException], exception: BaseExcept sys.__excepthook__(exception_type, exception, traceback) -def print_header(message: str) -> None: +def log_header(logger: logging.Logger, message: str) -> None: """ - Prints a header message with a decorative line above and below it. + Logs a header message with a decorative line above and below it. Args: - message: The header message to print. + logger: The logger to use for logging the header message. + message: The header message to log. """ line_separator = "#" * 100 formatted_message = f"########## {message}" formatted_message = f"{formatted_message} {line_separator[len(formatted_message) + 1 :]}" - print() # Print a blank line before the header - print(f"{Fore.GREEN}{Style.BRIGHT}{line_separator}{Style.RESET_ALL}") - print(f"{Fore.GREEN}{Style.BRIGHT}{formatted_message}{Style.RESET_ALL}") - print(f"{Fore.GREEN}{Style.BRIGHT}{line_separator}{Style.RESET_ALL}") - print() + logger.info("") # Log a blank line before the header + logger.info(f"{Fore.GREEN}{Style.BRIGHT}{line_separator}{Style.RESET_ALL}") + logger.info(f"{Fore.GREEN}{Style.BRIGHT}{formatted_message}{Style.RESET_ALL}") + logger.info(f"{Fore.GREEN}{Style.BRIGHT}{line_separator}{Style.RESET_ALL}") + logger.info("") diff --git a/src/fabric_cicd/fabric_workspace.py b/src/fabric_cicd/fabric_workspace.py index 600d5031..02e07b09 100644 --- a/src/fabric_cicd/fabric_workspace.py +++ b/src/fabric_cicd/fabric_workspace.py @@ -19,7 +19,7 @@ from fabric_cicd._common._exceptions import FailedPublishedItemStatusError, InputError, ParameterFileError, ParsingError from fabric_cicd._common._fabric_endpoint import FabricEndpoint, _generate_fabric_credential, _is_fabric_runtime from fabric_cicd._common._item import Item -from fabric_cicd._common._logging import print_header +from fabric_cicd._common._logging import log_header from fabric_cicd.constants import FeatureFlag, ItemType logger = logging.getLogger(__name__) @@ -242,7 +242,7 @@ def _refresh_parameter_file(self) -> None: """Load parameters if file is present.""" from fabric_cicd._parameter._parameter import Parameter - print_header("Validating Parameter File") + log_header(logger, "Validating Parameter File") # Initialize the parameter dict and Parameter object self.environment_parameter = {} @@ -827,7 +827,7 @@ def _publish_folders(self) -> None: """Publishes all folders from the repository.""" # Sort folders by the number of '/' in their paths (ascending order) sorted_folders = sorted(self.repository_folders.keys(), key=lambda path: path.count("/")) - print_header("Publishing Workspace Folders") + log_header(logger, "Publishing Workspace Folders") logger.info("Publishing Workspace Folders") for folder_path in sorted_folders: if folder_path in self.deployed_folders: diff --git a/src/fabric_cicd/publish.py b/src/fabric_cicd/publish.py index 1884dd02..35112159 100644 --- a/src/fabric_cicd/publish.py +++ b/src/fabric_cicd/publish.py @@ -19,7 +19,7 @@ load_config_file, ) from fabric_cicd._common._exceptions import FailedPublishedItemStatusError, InputError -from fabric_cicd._common._logging import print_header +from fabric_cicd._common._logging import log_header from fabric_cicd._common._validate_input import ( validate_environment, validate_fabric_workspace_obj, @@ -190,7 +190,7 @@ def publish_all_items( total_item_types = len(constants.SERIAL_ITEM_PUBLISH_ORDER) publishers_with_async_check: list[items.ItemPublisher] = [] for order_num, item_type in items.ItemPublisher.get_item_types_to_publish(fabric_workspace_obj): - print_header(f"Publishing Item {order_num}/{total_item_types}: {item_type.value}") + log_header(logger, f"Publishing Item {order_num}/{total_item_types}: {item_type.value}") publisher = items.ItemPublisher.create(item_type, fabric_workspace_obj) publisher.publish_all() if publisher.has_async_publish_check: @@ -198,7 +198,7 @@ def publish_all_items( # Check asynchronous publish status for relevant item types for publisher in publishers_with_async_check: - print_header(f"Checking {publisher.item_type} Publish State") + log_header(logger, f"Checking {publisher.item_type} Publish State") publisher.post_publish_all_check() # Return response data if feature flag is enabled and responses were collected @@ -266,7 +266,7 @@ def unpublish_all_orphan_items( fabric_workspace_obj._refresh_deployed_items() fabric_workspace_obj._refresh_repository_items() - print_header("Unpublishing Orphaned Items") + log_header(logger, "Unpublishing Orphaned Items") # Build unpublish order based on reversed publish order, scope, and feature flags for item_type in items.ItemPublisher.get_item_types_to_unpublish(fabric_workspace_obj): @@ -361,7 +361,7 @@ def deploy_with_config( msg = "Config file-based deployment is currently an experimental feature. Both 'enable_experimental_features' and 'enable_config_deploy' feature flags must be set." raise InputError(msg, logger) - print_header("Config-Based Deployment") + log_header(logger, "Config-Based Deployment") logger.info(f"Loading configuration from {config_file_path} for environment '{environment}'") # Validate environment