@loglayer/transport-pretty-terminal 2.0.0 → 3.0.1
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 +54 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -26
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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
|
@@ -345,6 +345,7 @@ var DetailView = (_class = class {
|
|
|
345
345
|
}
|
|
346
346
|
render() {
|
|
347
347
|
console.clear();
|
|
348
|
+
console.log("\n".repeat(5));
|
|
348
349
|
if (this.config.isJsonView) {
|
|
349
350
|
if (this.config.entry.data) {
|
|
350
351
|
console.log(JSON.stringify(JSON.parse(this.config.entry.data)));
|
|
@@ -368,7 +369,7 @@ ${this.config.config.separatorColor("TAB to return to detailed view")}`);
|
|
|
368
369
|
footerContent.push(nextLine);
|
|
369
370
|
}
|
|
370
371
|
footerContent.push("");
|
|
371
|
-
footerContent.push(this.config.config.separatorColor("
|
|
372
|
+
footerContent.push(this.config.config.separatorColor("\u2191/\u2193 scroll \u2022 Q/W page up/down \u2022 J raw JSON"));
|
|
372
373
|
footerContent.push(this.config.config.separatorColor("\u2190/\u2192 navigate \u2022 A/S first/last log \u2022 C toggle arrays"));
|
|
373
374
|
const mainContent = [];
|
|
374
375
|
const levelColor = getLevelColor(this.config.entry.level, this.config.config.colors);
|
|
@@ -409,9 +410,10 @@ ${this.config.config.separatorColor("TAB to return to detailed view")}`);
|
|
|
409
410
|
const footerHeight = footerContent.length;
|
|
410
411
|
const scrollIndicatorLines = 2;
|
|
411
412
|
const bufferSpace = 4;
|
|
413
|
+
const topPadding = 2;
|
|
412
414
|
const availableHeight = Math.max(
|
|
413
415
|
0,
|
|
414
|
-
process.stdout.rows - headerHeight - footerHeight - scrollIndicatorLines - bufferSpace
|
|
416
|
+
process.stdout.rows - headerHeight - footerHeight - scrollIndicatorLines - bufferSpace - topPadding
|
|
415
417
|
);
|
|
416
418
|
for (const line of headerContent) {
|
|
417
419
|
console.log(line);
|
|
@@ -426,6 +428,8 @@ ${this.config.config.separatorColor("TAB to return to detailed view")}`);
|
|
|
426
428
|
}
|
|
427
429
|
if (this.config.scrollPos + availableHeight < mainContent.length) {
|
|
428
430
|
console.log(chalk8.default.dim("\u2193 More content below"));
|
|
431
|
+
} else {
|
|
432
|
+
console.log(chalk8.default.dim("End of content"));
|
|
429
433
|
}
|
|
430
434
|
for (const line of footerContent) {
|
|
431
435
|
console.log(line);
|
|
@@ -439,9 +443,10 @@ ${this.config.config.separatorColor("TAB to return to detailed view")}`);
|
|
|
439
443
|
const footerHeight = 5;
|
|
440
444
|
const scrollIndicatorLines = 2;
|
|
441
445
|
const bufferSpace = 2;
|
|
446
|
+
const topPadding = 2;
|
|
442
447
|
const availableHeight = Math.max(
|
|
443
448
|
0,
|
|
444
|
-
process.stdout.rows - headerHeight - footerHeight - scrollIndicatorLines - bufferSpace
|
|
449
|
+
process.stdout.rows - headerHeight - footerHeight - scrollIndicatorLines - bufferSpace - topPadding
|
|
445
450
|
);
|
|
446
451
|
return Math.max(0, this.detailViewContent.length - availableHeight);
|
|
447
452
|
}
|
|
@@ -462,13 +467,11 @@ var SelectionView = class {
|
|
|
462
467
|
}
|
|
463
468
|
render() {
|
|
464
469
|
console.clear();
|
|
465
|
-
|
|
470
|
+
console.log("\n".repeat(5));
|
|
471
|
+
const filterHeight = this.config.filterText ? 2 : 0;
|
|
466
472
|
const footerHeight = 2;
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
console.log(chalk8.default.cyan("Filter:"), chalk8.default.white(this.config.filterText));
|
|
470
|
-
console.log(chalk8.default.dim("\u2500".repeat(this.termWidth)));
|
|
471
|
-
}
|
|
473
|
+
const topPadding = 5;
|
|
474
|
+
const availableHeight = process.stdout.rows - filterHeight - footerHeight - topPadding;
|
|
472
475
|
if (this.config.logs.length === 0) {
|
|
473
476
|
console.log(chalk8.default.yellow("No matching logs found"));
|
|
474
477
|
} else {
|
|
@@ -493,7 +496,16 @@ var SelectionView = class {
|
|
|
493
496
|
const message = entry.message;
|
|
494
497
|
const data = entry.data ? ` ${formatInlineData(JSON.parse(entry.data), this.config.config, 0, 0, true)}` : "";
|
|
495
498
|
const mainLine = `${prefix}${timestamp} ${chevron}${logId} ${message}${data}`;
|
|
496
|
-
|
|
499
|
+
const wrappedText = _wrapansi2.default.call(void 0, mainLine, this.termWidth - 2, { hard: true });
|
|
500
|
+
if (isSelected) {
|
|
501
|
+
const lines = wrappedText.split("\n");
|
|
502
|
+
console.log(lines[0]);
|
|
503
|
+
for (const line of lines.slice(1)) {
|
|
504
|
+
console.log(` ${this.config.config.selectorColor("\u2502")} ${line}`);
|
|
505
|
+
}
|
|
506
|
+
} else {
|
|
507
|
+
console.log(wrappedText);
|
|
508
|
+
}
|
|
497
509
|
});
|
|
498
510
|
if (endIdx < this.config.logs.length || this.config.newLogCount > 0) {
|
|
499
511
|
const moreLogsText = this.config.newLogCount > 0 ? this.config.config.selectorColor(
|
|
@@ -503,6 +515,10 @@ var SelectionView = class {
|
|
|
503
515
|
}
|
|
504
516
|
}
|
|
505
517
|
console.log(chalk8.default.dim("\nType to filter \u2022 Enter to view details \u2022 TAB to exit"));
|
|
518
|
+
if (this.config.filterText) {
|
|
519
|
+
console.log(chalk8.default.dim("\u2500".repeat(this.termWidth)));
|
|
520
|
+
console.log(chalk8.default.cyan("Filter:"), chalk8.default.white(this.config.filterText));
|
|
521
|
+
}
|
|
506
522
|
}
|
|
507
523
|
};
|
|
508
524
|
|
|
@@ -1050,6 +1066,17 @@ var UIManager = (_class3 = class {
|
|
|
1050
1066
|
}
|
|
1051
1067
|
return;
|
|
1052
1068
|
}
|
|
1069
|
+
if (!this.isSelectionMode && !this.isDetailView && (_optionalChain([key, 'optionalAccess', _3 => _3.name]) === "up" || _optionalChain([key, 'optionalAccess', _4 => _4.name]) === "down")) {
|
|
1070
|
+
this.isSelectionMode = true;
|
|
1071
|
+
this.filterText = "";
|
|
1072
|
+
this.isPaused = true;
|
|
1073
|
+
const storedLogs = this.storage.getAllLogs();
|
|
1074
|
+
this.logs = storedLogs;
|
|
1075
|
+
this.selectedIndex = key.name === "up" ? Math.max(0, this.logs.length - 1) : Math.max(0, this.logs.length - 1);
|
|
1076
|
+
this.renderer.renderSelectionView(this.logs, this.selectedIndex, this.filterText, this.selectionBuffer.length);
|
|
1077
|
+
this.startSelectionViewPolling();
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1053
1080
|
if (!this.isSelectionMode && !this.isDetailView && ch === "c") {
|
|
1054
1081
|
const newMode = this.renderer.cycleViewMode();
|
|
1055
1082
|
console.clear();
|
|
@@ -1068,22 +1095,6 @@ var UIManager = (_class3 = class {
|
|
|
1068
1095
|
}, 3e3);
|
|
1069
1096
|
return;
|
|
1070
1097
|
}
|
|
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
1098
|
if (this.isSelectionMode) {
|
|
1088
1099
|
if (key) {
|
|
1089
1100
|
switch (key.name) {
|
|
@@ -1147,6 +1158,7 @@ var UIManager = (_class3 = class {
|
|
|
1147
1158
|
}
|
|
1148
1159
|
case "tab": {
|
|
1149
1160
|
this.isSelectionMode = false;
|
|
1161
|
+
this.isPaused = false;
|
|
1150
1162
|
if (this.selectionViewPollInterval) {
|
|
1151
1163
|
clearInterval(this.selectionViewPollInterval);
|
|
1152
1164
|
this.selectionViewPollInterval = null;
|
|
@@ -1157,6 +1169,12 @@ var UIManager = (_class3 = class {
|
|
|
1157
1169
|
for (const entry of logs) {
|
|
1158
1170
|
this.renderer.renderLogLine(entry);
|
|
1159
1171
|
}
|
|
1172
|
+
if (this.selectionBuffer.length > 0) {
|
|
1173
|
+
for (const entry of this.selectionBuffer) {
|
|
1174
|
+
this.renderer.renderLogLine(entry);
|
|
1175
|
+
}
|
|
1176
|
+
this.selectionBuffer = [];
|
|
1177
|
+
}
|
|
1160
1178
|
return;
|
|
1161
1179
|
}
|
|
1162
1180
|
}
|
|
@@ -1169,7 +1187,7 @@ var UIManager = (_class3 = class {
|
|
|
1169
1187
|
}
|
|
1170
1188
|
}
|
|
1171
1189
|
if (this.isDetailView) {
|
|
1172
|
-
if (_optionalChain([key, 'optionalAccess',
|
|
1190
|
+
if (_optionalChain([key, 'optionalAccess', _5 => _5.name])) {
|
|
1173
1191
|
switch (key.name) {
|
|
1174
1192
|
case "up": {
|
|
1175
1193
|
this.renderer.scrollDetailView(-1);
|
|
@@ -1704,15 +1722,15 @@ var PrettyTerminalTransport = (_class4 = class _PrettyTerminalTransport extends
|
|
|
1704
1722
|
warn: chalk8.default.yellow,
|
|
1705
1723
|
error: chalk8.default.red,
|
|
1706
1724
|
fatal: chalk8.default.bgRed.white,
|
|
1707
|
-
..._optionalChain([theme, 'access',
|
|
1725
|
+
..._optionalChain([theme, 'access', _6 => _6.detailedView, 'optionalAccess', _7 => _7.colors])
|
|
1708
1726
|
},
|
|
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',
|
|
1727
|
+
logIdColor: _optionalChain([theme, 'access', _8 => _8.detailedView, 'optionalAccess', _9 => _9.logIdColor]) || chalk8.default.dim,
|
|
1728
|
+
dataValueColor: _optionalChain([theme, 'access', _10 => _10.detailedView, 'optionalAccess', _11 => _11.dataValueColor]) || chalk8.default.white,
|
|
1729
|
+
dataKeyColor: _optionalChain([theme, 'access', _12 => _12.detailedView, 'optionalAccess', _13 => _13.dataKeyColor]) || chalk8.default.dim,
|
|
1730
|
+
selectorColor: _optionalChain([theme, 'access', _14 => _14.detailedView, 'optionalAccess', _15 => _15.selectorColor]) || chalk8.default.cyan,
|
|
1731
|
+
headerColor: _optionalChain([theme, 'access', _16 => _16.detailedView, 'optionalAccess', _17 => _17.headerColor]) || chalk8.default.cyan,
|
|
1732
|
+
labelColor: _optionalChain([theme, 'access', _18 => _18.detailedView, 'optionalAccess', _19 => _19.labelColor]) || chalk8.default.cyan.bold,
|
|
1733
|
+
separatorColor: _optionalChain([theme, 'access', _20 => _20.detailedView, 'optionalAccess', _21 => _21.separatorColor]) || chalk8.default.dim,
|
|
1716
1734
|
// JSON formatting colors for detailed data view
|
|
1717
1735
|
jsonColors: {
|
|
1718
1736
|
keysColor: chalk8.default.yellow,
|
|
@@ -1735,7 +1753,7 @@ var PrettyTerminalTransport = (_class4 = class _PrettyTerminalTransport extends
|
|
|
1735
1753
|
// null/undefined
|
|
1736
1754
|
dateColor: chalk8.default.magenta,
|
|
1737
1755
|
// Date objects
|
|
1738
|
-
..._optionalChain([theme, 'access',
|
|
1756
|
+
..._optionalChain([theme, 'access', _22 => _22.detailedView, 'optionalAccess', _23 => _23.jsonColors])
|
|
1739
1757
|
}
|
|
1740
1758
|
};
|
|
1741
1759
|
this.storage = new LogStorage(logFile);
|