forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.js
More file actions
44 lines (36 loc) · 880 Bytes
/
logger.js
File metadata and controls
44 lines (36 loc) · 880 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const chalk = require('chalk');
const format = require('util').format;
/**
* Prefix.
*/
const prefix = ' ice-devtools';
const sep = chalk.gray('·');
/**
* Log a `message` to the console.
*
* @param {String} message
*/
exports.log = function(...args) {
const msg = format.apply(format, args);
console.log(chalk.white(prefix), sep, msg);
};
/**
* Log an error `message` to the console and exit.
*
* @param {String} message
*/
exports.fatal = function(...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);
};
/**
* Log a success `message` to the console and exit.
*
* @param {String} message
*/
exports.success = function(...args) {
const msg = format.apply(format, args);
console.log(chalk.white(prefix), sep, msg);
};