@loglayer/transport-pretty-terminal 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/index.cjs +39 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
A transport for the [LogLayer](https://loglayer.dev) logging library that pretty-prints logs printed in the terminal.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+

|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
@@ -16,10 +16,8 @@ A transport for the [LogLayer](https://loglayer.dev) logging library that pretty
|
|
|
16
16
|
- 🔎 **Search/Filter Functionality** - Find specific logs with powerful filtering capabilities
|
|
17
17
|
- 💅 **JSON Pretty Printing** - Beautifully formatted structured data with syntax highlighting
|
|
18
18
|
- 🎭 **Configurable Themes** - Choose from pre-built themes or customize your own colors
|
|
19
|
-
- 🔄 **Real-time Updates** - See logs as they happen with live updates
|
|
20
|
-
- 📊 **Context Awareness** - View previous and next logs when inspecting entries
|
|
21
19
|
|
|
22
|
-
## Installation
|
|
20
|
+
## Installation
|
|
23
21
|
|
|
24
22
|
Visit the [Pretty Terminal docs](https://loglayer.dev/transports/pretty-terminal)
|
|
25
23
|
for installation and usage.
|
package/dist/index.cjs
CHANGED
|
@@ -368,7 +368,7 @@ ${this.config.config.separatorColor("TAB to return to detailed view")}`);
|
|
|
368
368
|
footerContent.push(nextLine);
|
|
369
369
|
}
|
|
370
370
|
footerContent.push("");
|
|
371
|
-
footerContent.push(this.config.config.separatorColor("
|
|
371
|
+
footerContent.push(this.config.config.separatorColor("\u2191/\u2193 scroll \u2022 Q/W page up/down \u2022 J raw JSON"));
|
|
372
372
|
footerContent.push(this.config.config.separatorColor("\u2190/\u2192 navigate \u2022 A/S first/last log \u2022 C toggle arrays"));
|
|
373
373
|
const mainContent = [];
|
|
374
374
|
const levelColor = getLevelColor(this.config.entry.level, this.config.config.colors);
|
|
@@ -493,7 +493,16 @@ var SelectionView = class {
|
|
|
493
493
|
const message = entry.message;
|
|
494
494
|
const data = entry.data ? ` ${formatInlineData(JSON.parse(entry.data), this.config.config, 0, 0, true)}` : "";
|
|
495
495
|
const mainLine = `${prefix}${timestamp} ${chevron}${logId} ${message}${data}`;
|
|
496
|
-
|
|
496
|
+
const wrappedText = _wrapansi2.default.call(void 0, mainLine, this.termWidth - 2, { hard: true });
|
|
497
|
+
if (isSelected) {
|
|
498
|
+
const lines = wrappedText.split("\n");
|
|
499
|
+
console.log(lines[0]);
|
|
500
|
+
for (const line of lines.slice(1)) {
|
|
501
|
+
console.log(` ${this.config.config.selectorColor("\u2502")} ${line}`);
|
|
502
|
+
}
|
|
503
|
+
} else {
|
|
504
|
+
console.log(wrappedText);
|
|
505
|
+
}
|
|
497
506
|
});
|
|
498
507
|
if (endIdx < this.config.logs.length || this.config.newLogCount > 0) {
|
|
499
508
|
const moreLogsText = this.config.newLogCount > 0 ? this.config.config.selectorColor(
|
|
@@ -1050,6 +1059,17 @@ var UIManager = (_class3 = class {
|
|
|
1050
1059
|
}
|
|
1051
1060
|
return;
|
|
1052
1061
|
}
|
|
1062
|
+
if (!this.isSelectionMode && !this.isDetailView && (_optionalChain([key, 'optionalAccess', _3 => _3.name]) === "up" || _optionalChain([key, 'optionalAccess', _4 => _4.name]) === "down")) {
|
|
1063
|
+
this.isSelectionMode = true;
|
|
1064
|
+
this.filterText = "";
|
|
1065
|
+
this.isPaused = true;
|
|
1066
|
+
const storedLogs = this.storage.getAllLogs();
|
|
1067
|
+
this.logs = storedLogs;
|
|
1068
|
+
this.selectedIndex = key.name === "up" ? Math.max(0, this.logs.length - 1) : Math.max(0, this.logs.length - 1);
|
|
1069
|
+
this.renderer.renderSelectionView(this.logs, this.selectedIndex, this.filterText, this.selectionBuffer.length);
|
|
1070
|
+
this.startSelectionViewPolling();
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1053
1073
|
if (!this.isSelectionMode && !this.isDetailView && ch === "c") {
|
|
1054
1074
|
const newMode = this.renderer.cycleViewMode();
|
|
1055
1075
|
console.clear();
|
|
@@ -1068,22 +1088,6 @@ var UIManager = (_class3 = class {
|
|
|
1068
1088
|
}, 3e3);
|
|
1069
1089
|
return;
|
|
1070
1090
|
}
|
|
1071
|
-
if (!this.isSelectionMode && !this.isDetailView && _optionalChain([key, 'optionalAccess', _3 => _3.name]) === "tab") {
|
|
1072
|
-
this.isSelectionMode = true;
|
|
1073
|
-
this.filterText = "";
|
|
1074
|
-
if (this.isPaused) {
|
|
1075
|
-
this.selectionBuffer = [...this.pauseBuffer];
|
|
1076
|
-
this.pauseBuffer = [];
|
|
1077
|
-
const storedLogs = this.storage.getAllLogs();
|
|
1078
|
-
this.logs = storedLogs.slice(0, storedLogs.length - this.selectionBuffer.length);
|
|
1079
|
-
} else {
|
|
1080
|
-
this.updateFilteredLogs();
|
|
1081
|
-
}
|
|
1082
|
-
this.selectedIndex = Math.max(0, this.logs.length - 1);
|
|
1083
|
-
this.renderer.renderSelectionView(this.logs, this.selectedIndex, this.filterText, this.selectionBuffer.length);
|
|
1084
|
-
this.startSelectionViewPolling();
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
1091
|
if (this.isSelectionMode) {
|
|
1088
1092
|
if (key) {
|
|
1089
1093
|
switch (key.name) {
|
|
@@ -1147,6 +1151,7 @@ var UIManager = (_class3 = class {
|
|
|
1147
1151
|
}
|
|
1148
1152
|
case "tab": {
|
|
1149
1153
|
this.isSelectionMode = false;
|
|
1154
|
+
this.isPaused = false;
|
|
1150
1155
|
if (this.selectionViewPollInterval) {
|
|
1151
1156
|
clearInterval(this.selectionViewPollInterval);
|
|
1152
1157
|
this.selectionViewPollInterval = null;
|
|
@@ -1157,6 +1162,12 @@ var UIManager = (_class3 = class {
|
|
|
1157
1162
|
for (const entry of logs) {
|
|
1158
1163
|
this.renderer.renderLogLine(entry);
|
|
1159
1164
|
}
|
|
1165
|
+
if (this.selectionBuffer.length > 0) {
|
|
1166
|
+
for (const entry of this.selectionBuffer) {
|
|
1167
|
+
this.renderer.renderLogLine(entry);
|
|
1168
|
+
}
|
|
1169
|
+
this.selectionBuffer = [];
|
|
1170
|
+
}
|
|
1160
1171
|
return;
|
|
1161
1172
|
}
|
|
1162
1173
|
}
|
|
@@ -1169,7 +1180,7 @@ var UIManager = (_class3 = class {
|
|
|
1169
1180
|
}
|
|
1170
1181
|
}
|
|
1171
1182
|
if (this.isDetailView) {
|
|
1172
|
-
if (_optionalChain([key, 'optionalAccess',
|
|
1183
|
+
if (_optionalChain([key, 'optionalAccess', _5 => _5.name])) {
|
|
1173
1184
|
switch (key.name) {
|
|
1174
1185
|
case "up": {
|
|
1175
1186
|
this.renderer.scrollDetailView(-1);
|
|
@@ -1704,15 +1715,15 @@ var PrettyTerminalTransport = (_class4 = class _PrettyTerminalTransport extends
|
|
|
1704
1715
|
warn: chalk8.default.yellow,
|
|
1705
1716
|
error: chalk8.default.red,
|
|
1706
1717
|
fatal: chalk8.default.bgRed.white,
|
|
1707
|
-
..._optionalChain([theme, 'access',
|
|
1718
|
+
..._optionalChain([theme, 'access', _6 => _6.detailedView, 'optionalAccess', _7 => _7.colors])
|
|
1708
1719
|
},
|
|
1709
|
-
logIdColor: _optionalChain([theme, 'access',
|
|
1710
|
-
dataValueColor: _optionalChain([theme, 'access',
|
|
1711
|
-
dataKeyColor: _optionalChain([theme, 'access',
|
|
1712
|
-
selectorColor: _optionalChain([theme, 'access',
|
|
1713
|
-
headerColor: _optionalChain([theme, 'access',
|
|
1714
|
-
labelColor: _optionalChain([theme, 'access',
|
|
1715
|
-
separatorColor: _optionalChain([theme, 'access',
|
|
1720
|
+
logIdColor: _optionalChain([theme, 'access', _8 => _8.detailedView, 'optionalAccess', _9 => _9.logIdColor]) || chalk8.default.dim,
|
|
1721
|
+
dataValueColor: _optionalChain([theme, 'access', _10 => _10.detailedView, 'optionalAccess', _11 => _11.dataValueColor]) || chalk8.default.white,
|
|
1722
|
+
dataKeyColor: _optionalChain([theme, 'access', _12 => _12.detailedView, 'optionalAccess', _13 => _13.dataKeyColor]) || chalk8.default.dim,
|
|
1723
|
+
selectorColor: _optionalChain([theme, 'access', _14 => _14.detailedView, 'optionalAccess', _15 => _15.selectorColor]) || chalk8.default.cyan,
|
|
1724
|
+
headerColor: _optionalChain([theme, 'access', _16 => _16.detailedView, 'optionalAccess', _17 => _17.headerColor]) || chalk8.default.cyan,
|
|
1725
|
+
labelColor: _optionalChain([theme, 'access', _18 => _18.detailedView, 'optionalAccess', _19 => _19.labelColor]) || chalk8.default.cyan.bold,
|
|
1726
|
+
separatorColor: _optionalChain([theme, 'access', _20 => _20.detailedView, 'optionalAccess', _21 => _21.separatorColor]) || chalk8.default.dim,
|
|
1716
1727
|
// JSON formatting colors for detailed data view
|
|
1717
1728
|
jsonColors: {
|
|
1718
1729
|
keysColor: chalk8.default.yellow,
|
|
@@ -1735,7 +1746,7 @@ var PrettyTerminalTransport = (_class4 = class _PrettyTerminalTransport extends
|
|
|
1735
1746
|
// null/undefined
|
|
1736
1747
|
dateColor: chalk8.default.magenta,
|
|
1737
1748
|
// Date objects
|
|
1738
|
-
..._optionalChain([theme, 'access',
|
|
1749
|
+
..._optionalChain([theme, 'access', _22 => _22.detailedView, 'optionalAccess', _23 => _23.jsonColors])
|
|
1739
1750
|
}
|
|
1740
1751
|
};
|
|
1741
1752
|
this.storage = new LogStorage(logFile);
|