This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new b920aa084bf CAMEL-19033: camel-jbang - get trace -> trace
b920aa084bf is described below
commit b920aa084bffec2d981a3f744d48db7b43d22366
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Feb 17 14:43:06 2023 +0100
CAMEL-19033: camel-jbang - get trace -> trace
---
.../core/commands/action/CamelTraceAction.java | 53 ++++++++++++++++++++--
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java
index 8763e497765..66b63166117 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelTraceAction.java
@@ -727,10 +727,36 @@ public class CamelTraceAction extends ActionBaseCommand {
new Column().dataAlign(HorizontalAlign.LEFT).maxWidth(160,
OverflowBehaviour.NEWLINE)
.with(TableRow::valueAsString)));
}
+ String tab4 = null;
+ jo = r.exception;
+ if (jo != null) {
+ TableRow eRow = new TableRow("Exception", jo.getString("type"),
null, jo.get("message"));
+ tab4 = AsciiTable.getTable(AsciiTable.NO_BORDERS, List.of(eRow),
Arrays.asList(
+ new Column().dataAlign(HorizontalAlign.LEFT)
+ .minWidth(showExchangeProperties ? 10 :
8).with(TableRow::kindAsStringRed),
+ new Column().dataAlign(HorizontalAlign.LEFT)
+ .maxWidth(40,
OverflowBehaviour.ELLIPSIS_LEFT).with(TableRow::typeAsString),
+ new Column().dataAlign(HorizontalAlign.LEFT)
+ .maxWidth(80,
OverflowBehaviour.NEWLINE).with(TableRow::valueAsStringRed)));
+ }
+ // stacktrace only (span)
+ String tab5 = null;
+ if (jo != null) {
+ TableRow eRow = new TableRow("Stacktrace", null, null,
jo.get("stackTrace"));
+ tab5 = AsciiTable.getTable(AsciiTable.NO_BORDERS, List.of(eRow),
Arrays.asList(
+ new Column().dataAlign(HorizontalAlign.LEFT).maxWidth(160,
OverflowBehaviour.NEWLINE)
+ .with(TableRow::valueAsStringRed)));
+ }
String answer = tab1 + System.lineSeparator() + tab2;
if (tab3 != null) {
answer = answer + System.lineSeparator() + tab3;
}
+ if (tab4 != null) {
+ answer = answer + System.lineSeparator() + tab4;
+ }
+ if (tab5 != null) {
+ answer = answer + System.lineSeparator() + tab5;
+ }
return answer;
}
@@ -750,7 +776,8 @@ public class CamelTraceAction extends ActionBaseCommand {
return "Input";
}
} else if (r.last) {
- String s = r.parent.depth == 0 ? "Completed" : "Returning from " +
r.routeId;
+ String done = r.exception != null ? "Completed (exception)" :
"Completed (success)";
+ String s = r.parent.depth == 0 ? done : "Returning from " +
r.routeId;
if (loggingColor) {
return Ansi.ansi().fg(r.failed ? Ansi.Color.RED :
Ansi.Color.GREEN).a(s).reset().toString();
} else {
@@ -764,10 +791,11 @@ public class CamelTraceAction extends ActionBaseCommand {
return "Processing";
}
} else if (r.failed) {
+ String fail = r.exception != null ? "Exception" : "Failed";
if (loggingColor) {
- return
Ansi.ansi().fg(Ansi.Color.RED).a("Failed").reset().toString();
+ return
Ansi.ansi().fg(Ansi.Color.RED).a(fail).reset().toString();
} else {
- return "Failed";
+ return fail;
}
} else {
if (loggingColor) {
@@ -839,6 +867,17 @@ public class CamelTraceAction extends ActionBaseCommand {
return value != null ? value.toString() : "null";
}
+ String valueAsStringRed() {
+ if (value != null) {
+ if (loggingColor) {
+ return Ansi.ansi().fgRed().a(value).reset().toString();
+ } else {
+ return value.toString();
+ }
+ }
+ return "";
+ }
+
String keyAsString() {
if (key == null) {
return "";
@@ -850,6 +889,14 @@ public class CamelTraceAction extends ActionBaseCommand {
return kind;
}
+ String kindAsStringRed() {
+ if (loggingColor) {
+ return Ansi.ansi().fgRed().a(kind).reset().toString();
+ } else {
+ return kind;
+ }
+ }
+
String typeAsString() {
String s;
if (type == null) {