feat: 更新命令名称为dpml-prompt,保持PromptX品牌名称
This commit is contained in:
@ -1,90 +1,90 @@
|
||||
const chalk = require('chalk');
|
||||
const chalk = require('chalk')
|
||||
|
||||
/**
|
||||
* 日志工具
|
||||
* 提供彩色和格式化的日志输出
|
||||
*/
|
||||
class Logger {
|
||||
constructor(options = {}) {
|
||||
this.silent = options.silent || false;
|
||||
this.prefix = options.prefix || 'PromptX';
|
||||
constructor (options = {}) {
|
||||
this.silent = options.silent || false
|
||||
this.prefix = options.prefix || 'PromptX'
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息日志
|
||||
*/
|
||||
info(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.log(chalk.blue('ℹ'), message, ...args);
|
||||
info (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.log(chalk.blue('ℹ'), message, ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功日志
|
||||
*/
|
||||
success(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.log(chalk.green('✅'), message, ...args);
|
||||
success (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.log(chalk.green('✅'), message, ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 警告日志
|
||||
*/
|
||||
warn(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.log(chalk.yellow('⚠️'), chalk.yellow(message), ...args);
|
||||
warn (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.log(chalk.yellow('⚠️'), chalk.yellow(message), ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误日志
|
||||
*/
|
||||
error(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.error(chalk.red('❌'), chalk.red(message), ...args);
|
||||
error (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.error(chalk.red('❌'), chalk.red(message), ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 调试日志
|
||||
*/
|
||||
debug(message, ...args) {
|
||||
if (this.silent || !process.env.DEBUG) return;
|
||||
console.log(chalk.gray('🐛'), chalk.gray(message), ...args);
|
||||
debug (message, ...args) {
|
||||
if (this.silent || !process.env.DEBUG) return
|
||||
console.log(chalk.gray('🐛'), chalk.gray(message), ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤日志(用于显示进度)
|
||||
*/
|
||||
step(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.log(chalk.cyan('▶️'), message, ...args);
|
||||
step (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.log(chalk.cyan('▶️'), message, ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接输出(不带前缀)
|
||||
*/
|
||||
log(message, ...args) {
|
||||
if (this.silent) return;
|
||||
console.log(message, ...args);
|
||||
log (message, ...args) {
|
||||
if (this.silent) return
|
||||
console.log(message, ...args)
|
||||
}
|
||||
|
||||
/**
|
||||
* 空行
|
||||
*/
|
||||
newLine() {
|
||||
if (this.silent) return;
|
||||
console.log('');
|
||||
newLine () {
|
||||
if (this.silent) return
|
||||
console.log('')
|
||||
}
|
||||
|
||||
/**
|
||||
* 分隔线
|
||||
*/
|
||||
separator(char = '=', length = 80) {
|
||||
if (this.silent) return;
|
||||
console.log(chalk.gray(char.repeat(length)));
|
||||
separator (char = '=', length = 80) {
|
||||
if (this.silent) return
|
||||
console.log(chalk.gray(char.repeat(length)))
|
||||
}
|
||||
}
|
||||
|
||||
// 导出默认实例
|
||||
const logger = new Logger();
|
||||
const logger = new Logger()
|
||||
|
||||
module.exports = logger;
|
||||
module.exports.Logger = Logger;
|
||||
module.exports = logger
|
||||
module.exports.Logger = Logger
|
||||
|
||||
Reference in New Issue
Block a user