Files
openapi-clean-arch-gen/src/utils/logger.ts

44 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const colors = {
reset: '\x1b[0m',
bright: '\x1b[1m',
green: '\x1b[32m',
blue: '\x1b[34m',
yellow: '\x1b[33m',
red: '\x1b[31m',
cyan: '\x1b[36m'
} as const;
type Color = keyof typeof colors;
/** Prints a console message with the given ANSI colour. */
export function log(message: string, color: Color = 'reset'): void {
console.log(`${colors[color]}${message}${colors.reset}`);
}
/** Prints a success message (green). */
export function logSuccess(message: string): void {
log(`${message}`, 'green');
}
/** Prints an informational message (blue). */
export function logInfo(message: string): void {
log(` ${message}`, 'blue');
}
/** Prints a warning message (yellow). */
export function logWarning(message: string): void {
log(`⚠️ ${message}`, 'yellow');
}
/** Prints an error message (red). */
export function logError(message: string): void {
log(`${message}`, 'red');
}
/** Prints a step/stage header (cyan). */
export function logStep(message: string): void {
log(`\n🚀 ${message}`, 'cyan');
}
export { colors };