-
-
Notifications
You must be signed in to change notification settings - Fork 359
/
logger.js
39 lines (37 loc) · 1.22 KB
/
logger.js
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
"use strict";
const colors = require("colors");
const fs = require("fs");
const path = require("path");
module.exports = {
"format": " {{timestamp}} | {{title}} | {{message}}",
"dateformat": "yyyy-mm-dd | HH:MM:ss.l",
"filters": {
"log": colors.white,
"trace": colors.magenta,
"debug": colors.blue,
"info": colors.green,
"warn": colors.magenta,
"error": [colors.red, colors.bold],
},
"preprocess": (data) => {
data.title = data.title.toUpperCase();
while (data.title.length < 5) { data.title += " "; }
data.args = [...data.args];
if (data.args[0] && data.args[0].logpath) {
data.logpath = data.args[0].logpath;
data.args.shift();
}
},
"transport": (data) => {
// eslint-disable-next-line no-console
console.log(data.output);
const streamoptions = {
"flags": "a",
"encoding": "utf8",
};
fs.createWriteStream(path.join(__dirname, "claimer.log"), streamoptions).write(`\r\n${data.rawoutput}`);
if (data.logpath) {
fs.createWriteStream(data.logpath, streamoptions).write(`\r\n${data.rawoutput}`);
}
},
};