Skip to content

Commit

Permalink
adjust log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
pabender committed May 15, 2020
1 parent d42499a commit 2b0bf2c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
Expand Up @@ -8,6 +8,8 @@

import jmri.InstanceManager;
import jmri.ConfigureManager;
import org.apache.log4j.lf5.LogLevel;
import org.assertj.core.api.Condition;
import org.assertj.core.api.SoftAssertions;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
Expand Down Expand Up @@ -114,15 +116,16 @@ public WebServerAcceptanceSteps(jmri.InstanceManager instance) {
After(chrometags, NO_TIMEOUT, 0, () -> {
LogEntries logEntries = webDriver.manage().logs().get(LogType.BROWSER);

logEntries.forEach(System.out::println);

Condition<LogEntry> error = new Condition<>( o -> o.getMessage().startsWith("ERROR"),"error");
Condition<LogEntry> severe = new Condition<>( o -> o.getLevel().equals(LogLevel.SEVERE),"severe");

SoftAssertions softly = new SoftAssertions();
for (LogEntry logEntry : logEntries) {
softly.assertThat(logEntry.getLevel())
.withFailMessage(String.format("%s:%s:%s",webDriver.getWrappedDriver().getClass(),logEntry.getLevel().getName(),logEntry.getMessage()))
.isNotEqualTo(Level.WARNING)
.isNotEqualTo(Level.SEVERE);
softly.assertThat(logEntry.getMessage())
softly.assertThat(logEntry)
.withFailMessage(String.format("%s:%s:%s",webDriver.getWrappedDriver().getClass(),logEntry.getLevel().getName(),logEntry.getMessage()))
.doesNotStartWith("ERROR");
.is(error).is(severe);
}
softly.assertAll();
});
Expand Down
7 changes: 4 additions & 3 deletions java/test/jmri/util/web/BrowserFactory.java
Expand Up @@ -51,8 +51,9 @@ public static EventFiringWebDriver getBrowser(String browserName) {
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions()
.setBinary(firefoxBinary)
.setLogLevel(FirefoxDriverLogLevel.FATAL)
.addPreference("devtools.console.stdout.content",true);
.setLogLevel(FirefoxDriverLogLevel.FATAL);
// the following causes javascript console messages to be output to standard out.
//firefoxOptions.addPreference("devtools.console.stdout.content", true);

driver = new EventFiringWebDriver(new FirefoxDriver(firefoxOptions));
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Expand All @@ -71,7 +72,7 @@ public static EventFiringWebDriver getBrowser(String browserName) {
//}
chromeOptions.addArguments("--disable-extensions");
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.INFO);
logPrefs.enable(LogType.BROWSER, Level.SEVERE);
chromeOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

driver = new EventFiringWebDriver(new ChromeDriver(chromeOptions));
Expand Down
4 changes: 2 additions & 2 deletions web/js/jquery.jmri.js
Expand Up @@ -955,7 +955,7 @@
if (h) {
h.call(this, o);
} else if (!o.type) {
jmri.log("ERROR: missing type property in " + o);
console.error("ERROR: missing type property in " + o);
} else if (!h) {
jmri.log("Ignoring JSON type ", o.type);
}
Expand All @@ -965,7 +965,7 @@
if (h) {
h.call(this, m);
} else if (!m.type) {
jmri.log("ERROR: missing type property in " + m);
console.error("ERROR: missing type property in " + m);
} else if (!h) {
jmri.log("Ignoring JSON type ", m.type);
}
Expand Down
12 changes: 6 additions & 6 deletions web/js/panel.js
Expand Up @@ -2048,11 +2048,11 @@ function $drawTrackSegment($widget) {
var $ep1, $ep2;
[$ep1, $ep2] = $getEndPoints$($widget);
if (typeof $ep1 === "undefined") {
jmri.log("ERROR: can't draw tracksegment " + $widget.ident + ": connect1: " + $widget.connect1name + "." + $widget.type1 + " undefined.");
console.error("ERROR: can't draw tracksegment " + $widget.ident + ": connect1: " + $widget.connect1name + "." + $widget.type1 + " undefined.");
return;
}
if (typeof $ep2 === "undefined") {
jmri.log("ERROR: can't draw tracksegment " + $widget.ident + ": connect2: " + $widget.connect2name + "." + $widget.type2 + " undefined.");
console.error("ERROR: can't draw tracksegment " + $widget.ident + ": connect2: " + $widget.connect2name + "." + $widget.type2 + " undefined.");
return;
}

Expand Down Expand Up @@ -2257,7 +2257,7 @@ function $drawIcon($widget) {
$("#panel-area>#" + $widget.id + "-overlay").css(ovlCSS);
}
} else {
jmri.log("ERROR: image not defined for " + $widget.widgetType + " " + $widget.id + ", state=" + $widget.state + ", occ=" + $widget.occupancystate);
console.error("ERROR: image not defined for " + $widget.widgetType + " " + $widget.id + ", state=" + $widget.state + ", occ=" + $widget.occupancystate);
}
$setWidgetPosition($("#panel-area #" + $widget.id));
}
Expand Down Expand Up @@ -2860,7 +2860,7 @@ function $drawLayoutShape($widget) {
}
$gCtx.quadraticCurveTo(p[0], p[1], midR[0], midR[1]);
} else {
jmri.log("ERROR: unexpected LayoutShape point type '" + lspt + "' for " + $widget.ide);
console.error("ERROR: unexpected LayoutShape point type '" + lspt + "' for " + $widget.ide);
}
}); // $pts.each(function(idx, $lsp)

Expand Down Expand Up @@ -3473,7 +3473,7 @@ var $reDrawIcon = function($widget) {
} else if ($widget['defaulticon']) { //if state icon not found, use default icon if provided
$('img#' + $widget.id).attr('src', $widget['defaulticon']);
} else {
jmri.log("ERROR: image not defined for " + $widget.widgetType + " " + $widget.id + ", state=" + $widget.state + ", occ=" + $widget.occupancystate);
console.error("ERROR: image not defined for " + $widget.widgetType + " " + $widget.id + ", state=" + $widget.state + ", occ=" + $widget.occupancystate);
}
};

Expand Down Expand Up @@ -4013,7 +4013,7 @@ function setBlockColor(blockName, newColor) {
if (isDefined($blk)) {
$gBlks[blockName].blockcolor = newColor;
} else {
jmri.log("ERROR: block " + blockName + " not found for color " + newColor);
console.error("ERROR: block " + blockName + " not found for color " + newColor);
}
$redrawBlock(blockName);
}
Expand Down

0 comments on commit 2b0bf2c

Please sign in to comment.