forked from NativeScript/nativescript-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli-layout.ts
More file actions
38 lines (30 loc) · 954 Bytes
/
cli-layout.ts
File metadata and controls
38 lines (30 loc) · 954 Bytes
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
import { format } from "util";
import { getMessageWithBorders } from "../../helpers";
import { LoggingEvent } from "log4js";
import { LoggerConfigData, LoggerLevel } from "../../../constants";
import { EOL } from "os";
import { color } from "../../../color";
export function layout(config: any) {
return function (logEvent: LoggingEvent): string {
let msg = format.apply(null, logEvent.data);
if (logEvent.context[LoggerConfigData.wrapMessageWithBorders]) {
msg = getMessageWithBorders(msg);
}
if (!logEvent.context[LoggerConfigData.skipNewLine]) {
msg += EOL;
}
if (logEvent.level.isEqualTo(LoggerLevel.INFO)) {
return msg;
}
if (logEvent.level.isEqualTo(LoggerLevel.ERROR)) {
return color.styleText(["red", "bold"], msg);
}
if (logEvent.level.isEqualTo(LoggerLevel.WARN)) {
return color.yellow(msg);
}
if (logEvent.level.isEqualTo(LoggerLevel.TRACE)) {
return color.grey(msg);
}
return msg;
};
}