forked from zhw2590582/ArtPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
27 lines (22 loc) · 771 Bytes
/
logger.js
File metadata and controls
27 lines (22 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const chalk = require('chalk');
const { format } = require('util');
const prefix = 'artplayer-cli';
const sep = chalk.gray('·');
exports.log = function log(...args) {
const msg = format.apply(format, args);
console.log(chalk.white(prefix), sep, msg);
};
exports.fatal = function fatal(...args) {
if (args[0] instanceof Error) args[0] = args[0].message.trim();
const msg = format.apply(format, args);
console.error(chalk.red(prefix), sep, msg);
process.exit(1);
};
exports.success = function success(...args) {
const msg = format.apply(format, args);
console.log(chalk.green(prefix), sep, msg);
};
exports.warn = function warn(...args) {
const msg = format.apply(format, args);
console.log(chalk.yellow(prefix), sep, msg);
};