@contentstack/cli-utilities
Version:
Utilities for contentstack projects
34 lines (33 loc) • 1.53 kB
TypeScript
import { default as Logger } from './logger';
import { CLIErrorHandler } from './cli-error-handler';
import { ErrorContext } from '../interfaces';
declare const v2Logger: Logger;
declare const cliErrorHandler: CLIErrorHandler;
/**
* Handles and logs an error by classifying it and logging the relevant details.
*
* This function uses the `cliErrorHandler` to classify the provided error and logs
* the error details using `v2Logger`. If debug information is available, it logs
* additional debug details, including a stack trace if not already present.
*
* @param error - The error to be handled and logged. Can be of any type.
* @param context - Optional context information to assist in error classification
* and logging.
*
* @remarks
* - The error is always logged with its type, message, and other metadata.
* - If debug information is available, it is logged separately with a more specific
* debug type and additional details.
*/
declare function handleAndLogError(error: unknown, context?: ErrorContext, errorMessage?: string): void;
/**
* Get the log path for centralized logging
* Priority:
* 1. CS_CLI_LOG_PATH environment variable (user override)
* 2. User config (log.path from CLI config)
* 3. Current working directory + logs (where user ran the command)
* 4. Home directory (~/contentstack/logs) (fallback)
*/
declare function getLogPath(): string;
export { getSessionLogPath } from './session-path';
export { v2Logger, cliErrorHandler, handleAndLogError, getLogPath };