2016-10-09 21:14:02 +02:00
|
|
|
"use strict";
|
|
|
|
|
2018-03-02 19:28:54 +01:00
|
|
|
const colors = require("chalk");
|
2018-01-11 12:33:36 +01:00
|
|
|
const moment = require("moment");
|
2016-12-16 08:27:41 +01:00
|
|
|
const read = require("read");
|
2018-01-11 12:33:36 +01:00
|
|
|
const Helper = require("./helper");
|
2016-04-16 13:32:38 +02:00
|
|
|
|
2017-11-22 07:39:32 +01:00
|
|
|
function timestamp() {
|
|
|
|
const format = Helper.config.logs.format || "YYYY-MM-DD HH:mm:ss";
|
|
|
|
const tz = Helper.config.logs.timezone || "UTC+00:00";
|
|
|
|
const time = moment().utcOffset(tz).format(format);
|
2016-04-16 13:32:38 +02:00
|
|
|
|
2017-11-22 07:39:32 +01:00
|
|
|
return colors.dim(time);
|
2016-04-16 13:32:38 +02:00
|
|
|
}
|
|
|
|
|
2018-03-20 06:54:04 +01: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 07:13:43 +01:00
|
|
|
};
|