@sword-code-practice/sword-plugin-log
Version:
sword框架内置打印插件
26 lines (23 loc) • 534 B
JavaScript
import chalk from 'chalk';
const now = () => {
const _ = new Date();
return `${_.getFullYear()}-${_.getMonth() + 1}-${_.getDate()} ${_.getHours()}:${_.getMinutes()}:${_.getSeconds()}`;
};
const log = {
err: (v) => {
console.log(`${chalk.gray(now())} ${v}`);
},
info: (v) => {
console.log(`${chalk.gray(now())} ${chalk.yellow(v)}`);
},
success: (v) => {
console.log(`${chalk.gray(now())} ${chalk.green(v)}`);
}
};
const useLog = () => {
return {
name: "log",
log
};
};
export { log, useLog };