1 | const chalk = require('chalk');
|
2 | const { format } = require('util');
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | const prefix = '[ice-devtools]';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | exports.log = function (...args) {
|
15 | const msg = format.apply(format, args);
|
16 | console.log(chalk.white(prefix), msg);
|
17 | };
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | exports.info = function (...args) {
|
25 | const msg = format.apply(format, args);
|
26 | console.log(chalk.green(prefix), msg);
|
27 | };
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | exports.verbose = function (...args) {
|
33 | if (process.env.LOG_LEVEL !== 'verbose') {
|
34 | return;
|
35 | }
|
36 |
|
37 | const msg = format.apply(format, args);
|
38 | console.log(chalk.white(prefix), msg);
|
39 | };
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | exports.fatal = function (...args) {
|
47 | console.log();
|
48 | if (args[0] instanceof Error) {
|
49 | const errorName = args[0].name ? ` ${args[0].name}:` : '';
|
50 | console.error(chalk.red(prefix + errorName + args[0].message.trim()));
|
51 | console.error(args[0]);
|
52 | } else {
|
53 | console.error(chalk.red(prefix), ...args);
|
54 | }
|
55 | console.log();
|
56 | process.exit(1);
|
57 | };
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | exports.success = function (...args) {
|
65 | const msg = format.apply(format, args);
|
66 | console.log();
|
67 | console.log(chalk.white(prefix), msg);
|
68 | console.log();
|
69 | };
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | exports.warn = function (...args) {
|
78 | const msg = format.apply(format, args);
|
79 | console.log();
|
80 | console.log(chalk.yellow(prefix), msg);
|
81 | console.log();
|
82 | };
|