Skip to content

Conversation

@aman19K
Copy link
Contributor

@aman19K aman19K commented Jun 2, 2025

This PR introduces a standardized Logger and ErrorManager within the cli-utilities package to enforce consistent logging and error handling across CLI commands.

Changes Implemented
Added logger.ts utility with:

  • Multi-level logging: debug, info, success, warn, error
  • Dual output: console and centralized log files
  • Redaction of sensitive information (e.g., token, password, secret)

Added errorManager.ts utility with:

  • Error classification into API_ERROR, NETWORK_ERROR, CODE_ERROR
  • Centralized error handling logic

Evaluated and integrated with existing cli-error implementation:

  • Refactored or reused components as appropriate to avoid overlap
  • Exposed Logger and ErrorManager via cli-utilities public API

Added unit tests for:

  • Logging functionality
  • Error classification logic
  • Redaction handling

@aman19K aman19K changed the title feat: added error handler and logger support in cli feat: Add centralized Logger and ErrorManager with multi-level logging and error classification Jun 2, 2025
@aman19K aman19K marked this pull request as ready for review June 2, 2025 09:59
@aman19K aman19K requested a review from a team as a code owner June 2, 2025 09:59
Copy link
Contributor

@sunil-lakshman sunil-lakshman left a comment

Choose a reason for hiding this comment

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

LGTM

@netrajpatel netrajpatel requested a review from Copilot June 3, 2025 05:41
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 PR introduces a centralized Logger and ErrorManager to standardize multi-level logging and error classification across CLI utilities. Key changes include:

  • A new CLIErrorHandler class for robust error normalization, classification, and redaction.
  • Enhancements to TypeScript interfaces (LoggerConfig, PrintOptions, etc.) and logging constants.
  • Version updates in several package.json files to integrate the new cli-utilities improvements.

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/contentstack-utilities/src/logger/cliErrorHandler.ts Added new error handler with classification, debug payload extraction, and sensitive info redaction logic.
packages/contentstack-utilities/src/interfaces/index.ts Extended interfaces with LoggerConfig, PrintOptions, and LogType definitions.
packages/contentstack-utilities/src/constants/logging.ts Added logging level definitions and color mappings.
packages/contentstack-utilities/src/constants/errorTypes.ts Introduced standardized error type constants.
Package.json files in various packages Upgraded dependency versions to use the new cli-utilities version.

@aman19K aman19K merged commit 67f3924 into development Jun 3, 2025
10 checks passed
@aman19K aman19K deleted the feat/DX-3076-cli-logger branch June 3, 2025 07:17
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.

5 participants