From 6f2d6197907468db0ed549820fe56f4c10325944 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 30 Jan 2020 12:08:02 +0000 Subject: [PATCH 1/5] Allow logging to separate files It's easier to debug when the debug messages don't mess up the console output, and when they are written to files which you can search and scroll. --- assembly/src/bin/ship | 2 ++ assembly/src/conf/ship-logger.xml | 52 ++++++++++++++++++++++++++++--- build.gradle | 2 ++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/assembly/src/bin/ship b/assembly/src/bin/ship index 7e779a4..e9b74d0 100755 --- a/assembly/src/bin/ship +++ b/assembly/src/bin/ship @@ -23,6 +23,7 @@ export SHIP_BIN=${SHIP_BIN:-$SHIP_HOME/bin} export SHIP_CONF=${SHIP_CONF:-$SHIP_HOME/conf} export SHIP_DOC=${SHIP_DOC:-$SHIP_HOME/doc} export SHIP_LIB=${SHIP_LIB:-$SHIP_HOME/lib} +export SHIP_LOG=${SHIP_LOG:-$SHIP_HOME/log} JARS=$(find "$SHIP_LIB" -name 'bootstrap-*.jar') @@ -34,6 +35,7 @@ java -cp "$JARS" \ "-Dlogging.config=$SHIP_CONF/ship-logger.xml" \ "-Dship.lib=$SHIP_LIB" \ "-Dship.conf=$SHIP_CONF" \ + "-Dship.log=$SHIP_LOG" \ "-Dlogback.configurationFile=$SHIP_CONF/ship-logger.xml" ship.exec.LoaderLauncher $@ # Add this to debug the ship.bootstrap mechanism for loading classes diff --git a/assembly/src/conf/ship-logger.xml b/assembly/src/conf/ship-logger.xml index a0f6e1a..4252a87 100644 --- a/assembly/src/conf/ship-logger.xml +++ b/assembly/src/conf/ship-logger.xml @@ -9,9 +9,51 @@ %d{HH:mm} %highlight(%-5level) %cyan(%logger{15}) - %msg%n - - - + + + + + ${SHIP_LOG}/ship.log + true + + true + + + %-4relative [%thread] %-5level %logger{35} - %msg%n + + + INFO + + + + + ${SHIP_LOG}/trace.log + true + + true + + + %-4relative [%thread] %-5level %logger{35} - %msg%n + + + + + + + + + + + + + + + + + + diff --git a/build.gradle b/build.gradle index f7a135c..77de1f3 100644 --- a/build.gradle +++ b/build.gradle @@ -84,6 +84,8 @@ configure(javaProjects) { implementation 'org.slf4j:slf4j-api:1.7.25' runtime 'ch.qos.logback:logback-classic:1.2.3' + runtime 'org.codehaus.janino:janino:3.0.6' + runtime 'org.codehaus.janino:commons-compiler:3.0.6' testImplementation 'org.projectlombok:lombok:1.18.2' testImplementation 'junit:junit:4.12' testImplementation('org.powermock:powermock-api-mockito2:2.0.0-beta.5') { From 4e86f7bb188777c6b21396fcb089a99a02a51698 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 30 Jan 2020 12:09:03 +0000 Subject: [PATCH 2/5] Trace which test is being executed --- core/src/main/java/ship/command/TestProject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/ship/command/TestProject.java b/core/src/main/java/ship/command/TestProject.java index 0707ef3..a9c5c9f 100644 --- a/core/src/main/java/ship/command/TestProject.java +++ b/core/src/main/java/ship/command/TestProject.java @@ -87,7 +87,7 @@ protected void executeTest(final Builder builder, final String testPath) { final LuaSource executable = new LuaSource(buildDetails.getResult()); testReporter.clear(); - logger.trace("Executing test..."); + logger.trace("Executing test {} ...", testPath); testReporter.start(testPath); final TestResult testResult = new LuaRunner().run(executable); final TestReportNode testFile = testReporter.getCurrentTestFile(); From bcd2d616fdd55b5cdd4207f67f95eb2cadee3bc3 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 30 Jan 2020 16:18:42 +0000 Subject: [PATCH 3/5] improve LuaSource debugging --- core/src/main/java/ship/test/LuaSource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/ship/test/LuaSource.java b/core/src/main/java/ship/test/LuaSource.java index 7327a75..5130770 100644 --- a/core/src/main/java/ship/test/LuaSource.java +++ b/core/src/main/java/ship/test/LuaSource.java @@ -78,12 +78,12 @@ public String toString() { * @return formatted string */ public String toString(final int from, final int to, final List highlights) { - logger.debug("{} ~ {}", from, to); + logger.trace("toString({} ~ {})", from, to); final int digit = (int) (Math.log10(lines.length) + 1); assertTrue(from < to); final IntRange range = new IntRange(0, lines.length).select(new IntRange(from, to)); - logger.trace("{}", range); + logger.trace("range: {}", range); final StringJoiner joiner = new StringJoiner("\n"); IntStream.range(range.v1, range.v2) From ed60adc414f1da362032664eab8b4fd8426b1f9d Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 30 Jan 2020 16:21:28 +0000 Subject: [PATCH 4/5] show where log lines are coming from --- assembly/src/conf/ship-logger.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assembly/src/conf/ship-logger.xml b/assembly/src/conf/ship-logger.xml index 4252a87..f342ae4 100644 --- a/assembly/src/conf/ship-logger.xml +++ b/assembly/src/conf/ship-logger.xml @@ -20,7 +20,7 @@ - %-4relative [%thread] %-5level %logger{35} - %msg%n + %-4relative [%thread] %-5level %logger{35}:%line - %msg%n INFO @@ -35,7 +35,7 @@ - %-4relative [%thread] %-5level %logger{35} - %msg%n + %-4relative [%thread] %-5level %logger{35}:%line - %msg%n From c7483cb208efb02372951f7c5747d536b129f6e1 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 30 Jan 2020 16:21:13 +0000 Subject: [PATCH 5/5] reduce verbosity of BuildService --- assembly/src/conf/ship-logger.xml | 1 + core/src/main/java/ship/build/web/service/BuildService.java | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/assembly/src/conf/ship-logger.xml b/assembly/src/conf/ship-logger.xml index f342ae4..f4b8a75 100644 --- a/assembly/src/conf/ship-logger.xml +++ b/assembly/src/conf/ship-logger.xml @@ -42,6 +42,7 @@ + diff --git a/core/src/main/java/ship/build/web/service/BuildService.java b/core/src/main/java/ship/build/web/service/BuildService.java index 8745e01..cb7f813 100644 --- a/core/src/main/java/ship/build/web/service/BuildService.java +++ b/core/src/main/java/ship/build/web/service/BuildService.java @@ -42,7 +42,7 @@ public void addListener(final DangerousConsumer listener) { public void save(final BuildDetails buildDetails) { buildDetails.setSequence(sequence.incrementAndGet()); uuid2buildResult.put(buildDetails.getUuid(), buildDetails); - logger.info("New build detected: {}", buildDetails); + logger.debug("New build detected: {}", buildDetails); uuids.addFirst(buildDetails.getUuid()); while (100 < uuids.size()) { final String uuid = uuids.removeLast(); @@ -81,4 +81,4 @@ public List list(final String from, final int requestSize) { .collect(toList()); } } -} \ No newline at end of file +}