Skip to content

Conversation

@sellisd
Copy link
Contributor

@sellisd sellisd commented Nov 14, 2025

No description provided.

Removed duplicate code. Configure the location
of logs with an option instead of environment variable
@sellisd sellisd requested a review from Copilot November 14, 2025 15:46
Copilot finished reviewing on behalf of sellisd November 14, 2025 15:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request focuses on standardizing logging across the Babylon codebase to improve consistency and maintainability. The changes include migrating from hard-coded logger names to module-based naming, removing redundant log prefixes, and enhancing the logging infrastructure.

Key Changes:

  • Standardized logger initialization from getLogger("Babylon") to getLogger(__name__) across all modules for better log traceability
  • Removed redundant prefixes ([api], [powerbi], [babylon]) from log messages since the logger name now includes module information
  • Refactored logging setup in main.py with dedicated file handlers for standard logs and errors, plus a new --log-path CLI option

Reviewed Changes

Copilot reviewed 93 out of 93 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
Babylon/main.py Introduced setup_logging() function with file handlers and new --log-path option; removed test mode parameter
Babylon/utils/response.py Changed logger name to __name__ and added info logging for YAML file dumps
Babylon/test/api/datasets/test_datasets_service.py Updated test expectations to match API response format changes (list instead of dict) and added workspace-id parameter
Babylon/commands/macro/*.py Standardized logger initialization and removed log prefixes from messages
Babylon/commands/api/**/*.py Standardized logger names, removed JSON dumps from logs, removed redundant prefixes, and corrected spelling errors

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from Babylon.commands.api.solutions.services.solutions_security_svc import SolutionSecurityService

logger = getLogger("Babylon")
logger = getLogger("__name__")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger is incorrectly initialized with "__name__" as a string literal instead of the __name__ variable. This will result in all log messages from this module showing "name" instead of the actual module name.

Change to: logger = getLogger(__name__)

Copilot uses AI. Check for mistakes.
default_security = response.json()
logger.info(json.dumps(default_security, indent=2))
logger.info(f"[api] default RBAC access successfully setted with role {[role]}")
logger.info(f"default RBAC access successfully setted with role {[role]}")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "setted" should be corrected to "set" (proper past participle of "set").

Copilot uses AI. Check for mistakes.
from Babylon.commands.api.solutions.services.solutions_security_svc import SolutionSecurityService

logger = getLogger("Babylon")
logger = getLogger("__name__")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger is incorrectly initialized with "__name__" as a string literal instead of the __name__ variable. This will result in all log messages from this module showing "name" instead of the actual module name.

Change to: logger = getLogger(__name__)

Copilot uses AI. Check for mistakes.
return CommandResponse.fail()
run_templates = response.json()
logger.info(json.dumps(run_templates, indent=2))
logger.info(f"Retrieving all runtemplates in the solution {[service_state['api']['solution_id']]}")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message is placed after the API call returns successfully, which changes the logging behavior. The message says "Retrieving" (present tense) but appears after retrieval is complete. Consider either:

  1. Moving this line before line 39 (before the API call) to maintain the original intent, or
  2. Changing the message to past tense: "Retrieved all runtemplates from solution..."

Copilot uses AI. Check for mistakes.
env.store_state_in_cloud(state)
logger.info(json.dumps(organizations, indent=2))
ids = [o["id"] for o in organizations]
logger.info(f"Retrieved {ids} organizations details")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message format is incorrect. The f-string is trying to insert a list of IDs directly before the word "organizations", resulting in output like "Retrieved ['id1', 'id2'] organizations details".

Consider changing to: logger.info(f"Retrieved {len(ids)} organizations details: {ids}")

Suggested change
logger.info(f"Retrieved {ids} organizations details")
logger.info(f"Retrieved {len(ids)} organizations details: {ids}")

Copilot uses AI. Check for mistakes.
from Babylon.commands.api.solutions.services.solutions_security_svc import SolutionSecurityService

logger = getLogger("Babylon")
logger = getLogger("__name__")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger is incorrectly initialized with "__name__" as a string literal instead of the __name__ variable. This will result in all log messages from this module showing "name" instead of the actual module name.

Change to: logger = getLogger(__name__)

Copilot uses AI. Check for mistakes.
from Babylon.commands.api.solutions.services.solutions_security_svc import SolutionSecurityService

logger = getLogger("Babylon")
logger = getLogger("__name__")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger is incorrectly initialized with "__name__" as a string literal instead of the __name__ variable. This will result in all log messages from this module showing "name" instead of the actual module name.

Change to: logger = getLogger(__name__)

Copilot uses AI. Check for mistakes.
from Babylon.commands.api.solutions.services.solutions_security_svc import SolutionSecurityService

logger = getLogger("Babylon")
logger = getLogger("__name__")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger is incorrectly initialized with "__name__" as a string literal instead of the __name__ variable. This will result in all log messages from this module showing "name" instead of the actual module name.

Change to: logger = getLogger(__name__)

Copilot uses AI. Check for mistakes.
if len(datasets) and filter:
datasets = jmespath.search(filter, datasets)
logger.info(json.dumps(datasets, indent=2))
logger.info(f"Retrieved {[d.get('id') for d in datasets]} datastes")
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in log message: "datastes" should be "datasets".

Suggested change
logger.info(f"Retrieved {[d.get('id') for d in datasets]} datastes")
logger.info(f"Retrieved {[d.get('id') for d in datasets]} datasets")

Copilot uses AI. Check for mistakes.
@sellisd sellisd requested a review from Copilot November 14, 2025 16:07
Copilot finished reviewing on behalf of sellisd November 14, 2025 16:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 94 out of 94 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

log_file_handler.setLevel(logging.INFO)
error_file_handler = logging.FileHandler(log_path / "babylon.error")
error_file_handler.setLevel(logging.WARNING)
logging.basicConfig(format="%(asctime)s:%(levelname)s:%(name)s:%(message)s",
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent logging format: The format string uses %(name)s to include the logger name, but line 19 changes the root logger from getLogger("Babylon") to getLogger() (root logger). This means all loggers will now use their module names (e.g., "Babylon.commands.api.workspaces.create") which could make the log format string %(name)s produce very long entries. Consider adjusting the format to truncate or use a shorter format for the name.

Copilot uses AI. Check for mistakes.


def setup_logging(log_path: pathlibPath = pathlibPath.cwd()) -> None:
import click # noqa F401
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import: import click # noqa F401 is imported but not used in this function. The import appears to be only for the tracebacks_suppress parameter, but it's already imported at the top level of the module.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
print(response.text)
return CommandResponse.success(response.text)
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed return type from JSON to text: The function now returns response.text instead of response.json(). This changes the API behavior - callers expecting JSON data will now receive a string. This also adds a print() statement that outputs directly to stdout, which may not be desired in all contexts (e.g., when output is redirected or when running in non-interactive mode).

Copilot uses AI. Check for mistakes.
@sellisd sellisd force-pushed the DSE/log_standardization_PROD-14939 branch from 7c62e9e to 205d019 Compare November 14, 2025 16:18
@sellisd sellisd marked this pull request as ready for review November 14, 2025 16:19
@sellisd sellisd requested a review from MohcineTor November 14, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants