2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2018-03-02 18:28:54 +00:00
|
|
|
const colors = require("chalk");
|
2016-12-16 07:27:41 +00:00
|
|
|
const read = require("read");
|
2016-04-16 11:32:38 +00:00
|
|
|
|
2017-11-22 06:39:32 +00:00
|
|
|
function timestamp() {
|
2019-07-17 09:33:59 +00:00
|
|
|
const datetime = new Date()
|
|
|
|
.toISOString()
|
|
|
|
.split(".")[0]
|
|
|
|
.replace("T", " ");
|
2018-09-20 11:15:05 +00:00
|
|
|
|
|
|
|
return colors.dim(datetime);
|
2016-04-16 11:32:38 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 05:54:04 +00:00
|
|
|
module.exports = {
|
|
|
|
/* eslint-disable no-console */
|
|
|
|
error(...args) {
|
|
|
|
console.error(timestamp(), colors.red("[ERROR]"), ...args);
|
|
|
|
},
|
|
|
|
warn(...args) {
|
|
|
|
console.error(timestamp(), colors.yellow("[WARN]"), ...args);
|
|
|
|
},
|
|
|
|
info(...args) {
|
|
|
|
console.log(timestamp(), colors.blue("[INFO]"), ...args);
|
|
|
|
},
|
|
|
|
debug(...args) {
|
|
|
|
console.log(timestamp(), colors.green("[DEBUG]"), ...args);
|
|
|
|
},
|
|
|
|
raw(...args) {
|
|
|
|
console.log(...args);
|
|
|
|
},
|
|
|
|
/* eslint-enable no-console */
|
|
|
|
|
|
|
|
prompt(options, callback) {
|
|
|
|
options.prompt = [timestamp(), colors.cyan("[PROMPT]"), options.text].join(" ");
|
|
|
|
read(options, callback);
|
|
|
|
},
|
2016-12-15 06:13:43 +00:00
|
|
|
};
|