@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/dist/index.js CHANGED
@@ -345,6 +345,7 @@ var DetailView = 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("TAB to exit \u2022 \u2191/\u2193 scroll \u2022 Q/W page up/down \u2022 J raw JSON"));
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(chalk3.dim("\u2193 More content below"));
431
+ } else {
432
+ console.log(chalk3.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
- const headerHeight = this.config.filterText ? 2 : 0;
470
+ console.log("\n".repeat(5));
471
+ const filterHeight = this.config.filterText ? 2 : 0;
466
472
  const footerHeight = 2;
467
- const availableHeight = process.stdout.rows - headerHeight - footerHeight;
468
- if (this.config.filterText) {
469
- console.log(chalk4.cyan("Filter:"), chalk4.white(this.config.filterText));
470
- console.log(chalk4.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(chalk4.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
- console.log(wrap3(mainLine, this.termWidth - 2, { hard: true }));
499
+ const wrappedText = wrap3(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(chalk4.dim("\nType to filter \u2022 Enter to view details \u2022 TAB to exit"));
518
+ if (this.config.filterText) {
519
+ console.log(chalk4.dim("\u2500".repeat(this.termWidth)));
520
+ console.log(chalk4.cyan("Filter:"), chalk4.white(this.config.filterText));
521
+ }
506
522
  }
507
523
  };
508
524
 
@@ -1050,6 +1066,17 @@ var UIManager = class {
1050
1066
  }
1051
1067
  return;
1052
1068
  }
1069
+ if (!this.isSelectionMode && !this.isDetailView && (key?.name === "up" || key?.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 = class {
1068
1095
  }, 3e3);
1069
1096
  return;
1070
1097
  }
1071
- if (!this.isSelectionMode && !this.isDetailView && key?.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 = 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 = 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
  }