-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlogger.ts
More file actions
56 lines (51 loc) · 1.1 KB
/
logger.ts
File metadata and controls
56 lines (51 loc) · 1.1 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import pino from "pino";
const customTransport = {
write: (log: never) => {
const parsed = JSON.parse(log);
const { level, msg } = parsed;
let color = "\x1b[0m"; // default
switch (level) {
case 1:
color = "\x1b[31m";
break; // error - red
case 2:
color = "\x1b[34m";
break; // info - blue
case 3:
color = "\x1b[33m";
break; // warn - yellow
case 7:
color = "\x1b[36m";
break; // attemptBuy - cyan
case 8:
color = "\x1b[32m";
break; // buy - green
case 9:
color = "\x1b[35m";
break; // sell - magenta
case 10:
color = "\x1b[93m";
break; // attemptSell - bright yellow
default:
color = "\x1b[0m";
break;
}
process.stdout.write(`${color}${msg}\x1b[0m\n`);
},
};
export const logger = pino(
{
level: "error",
customLevels: {
error: 1,
info: 2,
warn: 3,
attemptBuy: 7,
buy: 8,
sell: 9,
attemptSell: 10,
},
useOnlyCustomLevels: true,
},
customTransport,
);