From 587bc68abd3f19d20bf8e6ce27032b5279f767d3 Mon Sep 17 00:00:00 2001 From: Aman Sharma Date: Wed, 26 Mar 2025 15:15:41 +0100 Subject: [PATCH] refactor: log relative paths for file --- src/macaron/__main__.py | 6 +++--- src/macaron/repo_finder/repo_utils.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/macaron/__main__.py b/src/macaron/__main__.py index da727cdaa..6321ea6fd 100644 --- a/src/macaron/__main__.py +++ b/src/macaron/__main__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022 - 2024, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/. """This is the main entrypoint to run Macaron.""" @@ -537,9 +537,9 @@ def main(argv: list[str] | None = None) -> None: sys.exit(os.EX_USAGE) if os.path.isdir(args.output_dir): - logger.info("Setting the output directory to %s", args.output_dir) + logger.info("Setting the output directory to %s", os.path.relpath(args.output_dir, os.getcwd())) else: - logger.info("No directory at %s. Creating one ...", args.output_dir) + logger.info("No directory at %s. Creating one ...", os.path.relpath(args.output_dir, os.getcwd())) os.makedirs(args.output_dir) # Add file handler to the root logger. Remove stream handler from the diff --git a/src/macaron/repo_finder/repo_utils.py b/src/macaron/repo_finder/repo_utils.py index 0f9ca2683..e1b0be7af 100644 --- a/src/macaron/repo_finder/repo_utils.py +++ b/src/macaron/repo_finder/repo_utils.py @@ -75,7 +75,7 @@ def generate_report(purl: str, commit: str, repo: str, target_dir: str) -> bool: fullpath = f"{target_dir}/{filename}" os.makedirs(os.path.dirname(fullpath), exist_ok=True) - logger.info("Writing report to: %s", fullpath) + logger.info("Writing report to: %s", os.path.relpath(fullpath, os.getcwd())) try: with open(fullpath, "w", encoding="utf-8") as file: @@ -84,7 +84,7 @@ def generate_report(purl: str, commit: str, repo: str, target_dir: str) -> bool: logger.debug("Failed to write report to file: %s", error) return False - logger.info("Report written to: %s", fullpath) + logger.info("Report written to: %s", os.path.relpath(fullpath, os.getcwd())) return True