Commit e2184ebf authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

add StdErr StdOut logger to main entry points

parent 8425cf7b
Pipeline #84730 passed with stages
in 102 minutes and 32 seconds
......@@ -3,6 +3,7 @@ package org.vadere.gui.postvisualization;
import org.vadere.gui.postvisualization.view.PostvisualizationWindow;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import org.vadere.util.logging.StdOutErrLog;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
......@@ -14,6 +15,7 @@ public class PostVisualisation {
private static Logger logger = Logger.getLogger(PostVisualisation.class);
public static void main(String[] args) {
StdOutErrLog.addStdOutErrToLog();
logger.info("starting post visualization ...");
// load settings
loadPreferences();
......
......@@ -12,6 +12,7 @@ import org.vadere.gui.postvisualization.view.PostvisualizationRenderer;
import org.vadere.simulator.projects.io.IOOutput;
import org.vadere.simulator.projects.io.TrajectoryReader;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.StdOutErrLog;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
......@@ -29,6 +30,7 @@ import java.util.Optional;
public class PostVisualizationConsole {
public static void main(final String... args) {
StdOutErrLog.addStdOutErrToLog();
ArgumentParser parser = ArgumentParsers.newArgumentParser("prog")
.defaultHelp(true)
.description("Runs the VADERE Postvisualization for image generation.");
......
......@@ -3,6 +3,7 @@ package org.vadere.gui.projectview;
import org.apache.commons.lang3.time.StopWatch;
import org.vadere.gui.components.utils.Recorder;
import org.vadere.meshing.mesh.gen.MeshRenderer;
import org.vadere.util.logging.StdOutErrLog;
import org.vadere.util.visualization.ColorHelper;
import org.vadere.util.geometry.GeometryUtils;
import org.vadere.meshing.mesh.gen.AFace;
......@@ -30,6 +31,7 @@ import javax.swing.*;
public class RecordTriangulationMovie {
public static void main(String... args) throws IOException {
StdOutErrLog.addStdOutErrToLog();
VPolygon boundary = GeometryUtils.polygonFromPoints2D(
new VPoint(0,0),
new VPoint(0, 1),
......
......@@ -5,6 +5,7 @@ import org.vadere.gui.components.utils.Messages;
import org.vadere.gui.projectview.view.ProjectView;
import org.vadere.util.io.IOUtils;
import org.vadere.util.logging.Logger;
import org.vadere.util.logging.StdOutErrLog;
import java.io.IOException;
import java.util.prefs.BackingStoreException;
......@@ -21,6 +22,7 @@ public class VadereApplication {
private static Logger logger = Logger.getLogger(VadereApplication.class);
public static void main(String[] args) {
StdOutErrLog.addStdOutErrToLog();
logger.info("starting Vadere GUI...");
// load settings
loadPreferences();
......
......@@ -4,7 +4,7 @@ property.filename = logs
appenders = console, file
appender.console.type = Console
appender.console.name = STDOUT
appender.console.name = CONSOLE
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{ABSOLUTE} %5p %c{1}:%L - %m%n
......@@ -18,7 +18,14 @@ appender.file.policies.type = Policies
appender.file.policies.size.type = SizeBasedTriggeringPolicy
appender.file.policies.size.size = 10000KB
loggers = stdOutErr
logger.stdOutErr.name = STDOUTERR
logger.stdOutErr.level = trace
logger.stdOutErr.appenderRefs = file
logger.stdOutErr.appenderRef.file.ref = FILE
logger.stdOutErr.additivity = false
rootLogger.level = trace
rootLogger.appenderRefs = console, file
rootLogger.appenderRef.console.ref = STDOUT
rootLogger.appenderRef.console.ref = CONSOLE
rootLogger.appenderRef.file.ref = FILE
\ No newline at end of file
......@@ -17,8 +17,7 @@ public class AssertionLog {
logger.info("Test Info");
logger.warn("Test Warn");
logger.error("Test Err");
logger.debug("Test Debug %d", 5);
logger.debugf("Test Debug %d", 5);
assert false : "Fail";
}
......
......@@ -17,6 +17,7 @@ import org.vadere.simulator.entrypoints.cmd.commands.SetLogNameCommand;
import org.vadere.simulator.entrypoints.cmd.commands.SuqSubCommand;
import org.vadere.simulator.utils.scenariochecker.ScenarioChecker;
import org.vadere.util.logging.Logger;
import org.vadere.util.logging.StdOutErrLog;
/**
......@@ -33,6 +34,7 @@ public class VadereConsole {
ArgumentParser parser = createArgumentParser();
try {
StdOutErrLog.addStdOutErrToLog();
Namespace ns = parser.parseArgs(args);
SubCommandRunner sRunner = ns.get("func");
sRunner.run(ns, parser);
......
......@@ -4,8 +4,11 @@ package org.vadere.util.logging;
import java.io.PrintStream;
public class StdOutErrLog {
private static final Logger logger = Logger.getLogger(StdOutErrLog.class);
private static final Logger logger = Logger.getLogger("STDOUTERR");
/**
* redirect StdOut and StdErr to logfile with custom log level STDOUT and STDERR.
*/
public static void addStdOutErrToLog(){
System.setOut(redirectOut(System.out));
System.setErr(redirectErr(System.err));
......@@ -16,7 +19,7 @@ public class StdOutErrLog {
return new PrintStream(baseStream){
public void print(final String s){
baseStream.print(s);
logger.info(s);
logger.stdout(s);
}
};
}
......@@ -26,7 +29,7 @@ public class StdOutErrLog {
return new PrintStream(baseStream){
public void print(final String s){
baseStream.print(s);
logger.error(s);
logger.stderr(s);
}
};
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment