UNPKG

651 BJavaScriptView Raw
1const logUpdate = require("log-update");
2
3module.exports = log;
4
5function log(msg, ...rest) {
6 const date = new Date().toLocaleString();
7
8 console.log("[" + date + "] - " + msg, ...rest);
9}
10
11log.update = function (msg) {
12 const date = new Date().toLocaleString();
13 logUpdate("[" + date + "] - " + msg);
14};
15
16log.clear = function () {
17 logUpdate.clear();
18};
19
20let logList = [];
21
22log.save = function (msg) {
23 logList.push(msg);
24};
25log.flush = function () {
26 if (logList.length) {
27 logList.forEach(msg => console.log(msg));
28 logList = [];
29 }
30};
31
32log.msg = function (msg) {
33 const date = new Date().toLocaleString();
34 return "[" + date + "] - " + msg;
35};