smart-ast-analyzer
Version:
Advanced AST-based project analysis tool with deep complexity analysis, security scanning, and optional AI enhancement
53 lines (45 loc) ⢠1.08 kB
JavaScript
const chalk = require('chalk');
const ora = require('ora');
class Logger {
constructor(verbose = false) {
this.verbose = verbose;
this.spinner = null;
}
start(message) {
console.log(chalk.cyan.bold(`\nš ${message}\n`));
}
info(message) {
if (this.spinner) this.spinner.stop();
this.spinner = ora(message).start();
}
success(message) {
if (this.spinner) {
this.spinner.succeed(message);
this.spinner = null;
} else {
console.log(chalk.green(`ā
${message}`));
}
}
error(message, error) {
if (this.spinner) {
this.spinner.fail(message);
this.spinner = null;
} else {
console.log(chalk.red(`ā ${message}`));
}
if (error && this.verbose) {
console.error(error);
}
}
warn(message) {
if (this.spinner) this.spinner.stop();
console.log(chalk.yellow(`ā ļø ${message}`));
if (this.spinner) this.spinner.start();
}
debug(message) {
if (this.verbose) {
console.log(chalk.gray(`[DEBUG] ${message}`));
}
}
}
module.exports = Logger;