Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.gradle.common;

import de.se_rwth.commons.logging.ConsoleLogHook;
import de.se_rwth.commons.logging.Log;
import de.se_rwth.commons.logging.RichConsoleLogHook;

import java.util.ArrayList;

Expand All @@ -17,7 +17,7 @@ public static void init() {
l.isDEBUG = false;
l.isINFO = true;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
l.errorHook = new GradleErrorHook();
GradleLog.setLog(l);
}
Expand All @@ -31,7 +31,7 @@ public static void initDEBUG() {
l.isTRACE = true;
l.isINFO = true;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
l.errorHook = new GradleErrorHook();
GradleLog.setLog(l);
}
Expand All @@ -45,7 +45,7 @@ public static void initWARN() {
l.isDEBUG = false;
l.isINFO = false;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
l.errorHook = new GradleErrorHook();
GradleLog.setLog(l);
}
Expand All @@ -59,7 +59,7 @@ public static void initTRACE() {
l.isDEBUG = false;
l.isINFO = false;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
l.errorHook = new GradleErrorHook();
GradleLog.setLog(l);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static void init() {
l.isDEBUG = false;
l.isINFO = true;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
l.errorHook = getDefaultErrorHook();
Log.setLog(l);
}
Expand Down Expand Up @@ -112,7 +112,7 @@ public static void initInteractive() {
l.isINFO = true;
l.isInteractive = true;
l.logHooks = new ArrayList<>();
l.logHooks.add(new ConsoleLogHook());
l.logHooks.add(new RichConsoleLogHook());
Log.setLog(l);
}

Expand Down Expand Up @@ -161,7 +161,7 @@ public static void internalRemove() {
protected Log() {
// TODO: Workaround by ALU to fix the NPE
this.logHooks = new ArrayList<>();
this.logHooks.add(new ConsoleLogHook());
this.logHooks.add(new RichConsoleLogHook());
this.errorHook = getDefaultErrorHook();
// TODO: END Workaround by ALU to fix the NPE
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void init() {
*/
public static void initPlusLog() {
init();
Log.getLog().logHooks.add(new ConsoleLogHook());
Log.getLog().logHooks.add(new RichConsoleLogHook());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public void testErrorWithoutQF() {
Assertions.assertFalse(setup.exitCalled);
// Then check actual output
Assertions.assertEquals(
"[ERROR] First error in line " + e1.getLine() + System.lineSeparator() +
"[ERROR] Second error in line " + e2.getLine() + System.lineSeparator() +
"[ERROR] Third error in line " + e3.getLine() + System.lineSeparator()
RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " First error in line " + e1.getLine() + System.lineSeparator() +
RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " Second error in line " + e2.getLine() + System.lineSeparator() +
RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " Third error in line " + e3.getLine() + System.lineSeparator()
, setup.real_std.toString());
Assertions.assertEquals("", setup.real_ste.toString());
});
Expand All @@ -205,23 +205,23 @@ public void testErrorStacktraceWithoutQF() {
Assertions.assertFalse(setup.exitCalled);
// Then check actual output
String[] real_std = setup.real_std.toString().split(System.lineSeparator());
Assertions.assertEquals("[ERROR] First error in line " + e1.getLine(), real_std[0]);
Assertions.assertEquals(RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " First error in line " + e1.getLine(), real_std[0]);
Assertions.assertTrue(real_std[1].startsWith("\tat de.se_rwth.commons.logging.Log.error(Log.java:"), real_std[1]);
// We now skip over the stacktrace until we find the exception
int lineCounter = 1;
while (!real_std[lineCounter].startsWith("Caused by ")) {
assertFalse(real_std[lineCounter].startsWith("[ERROR]"));
assertFalse(real_std[lineCounter].startsWith(RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET));
lineCounter++;
}
Assertions.assertEquals("Caused by java.lang.RuntimeException: E1", real_std[lineCounter]);
lineCounter++;
while (!real_std[lineCounter].startsWith("[ERROR] Second error in line " + e2.getLine())) {
while (!real_std[lineCounter].startsWith(RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " Second error in line " + e2.getLine())) {
assertFalse(real_std[lineCounter].startsWith("Caused by"));
lineCounter++;
}
lineCounter++;
while (!real_std[lineCounter].startsWith("Caused by ")) {
assertFalse(real_std[lineCounter].startsWith("[ERROR]"));
assertFalse(real_std[lineCounter].startsWith(RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET));
lineCounter++;
}
Assertions.assertEquals("Caused by java.lang.RuntimeException: E2", real_std[lineCounter]);
Expand All @@ -243,7 +243,7 @@ public void testErrorQF() {
}, setup -> {
Assertions.assertTrue(setup.exitCalled);
Assertions.assertEquals(
"[ERROR] First error in line " + e1.getLine() + System.lineSeparator()
RichConsoleLogHook.RED_BOLD + "[ERROR]" + RichConsoleLogHook.RESET + " First error in line " + e1.getLine() + System.lineSeparator()
, setup.real_std.toString());
Assertions.assertEquals("", setup.real_ste.toString());
});
Expand Down
Loading