Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

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

Add loglevel switch to vadereConsole (close #132).

Move vadereConsole files to own package within simulation-module
parent 4f89a94b
......@@ -82,7 +82,7 @@
<configuration>
<archive>
<manifest>
<mainClass>org.vadere.simulator.entrypoints.VadereConsole</mainClass>
<mainClass>org.vadere.simulator.entrypoints.cmd.VadereConsole</mainClass>
</manifest>
</archive>
<descriptorRefs>
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd;
public enum SubCommand {
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.impl.Arguments;
......@@ -9,6 +9,13 @@ import net.sourceforge.argparse4j.inf.Subparser;
import net.sourceforge.argparse4j.inf.Subparsers;
import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.entrypoints.cmd.commands.MigrationSubCommand;
import org.vadere.simulator.entrypoints.cmd.commands.ProjectRunSubCommand;
import org.vadere.simulator.entrypoints.cmd.commands.ScenarioRunSubCommand;
import org.vadere.simulator.entrypoints.cmd.commands.SetLogLevelCommand;
import org.vadere.simulator.entrypoints.cmd.commands.SuqSubCommand;
/**
* Provides the possibility to start VADERE in console mode.
*
......@@ -20,7 +27,9 @@ public class VadereConsole {
public static void main(String[] args) {
ArgumentParser parser = createArgumentParser();
// args = new String[]{"migrate", "--create-new-version", "0.6", "/home/lphex/hm.d/vadere/VadereSimulator/resources"};
// args = new String[]{"--loglevel", "OFF", "scenario-run", "-o", "/tmp", "-f", "/home/lphex/hm.d/vadere/VadereModelTests/TestOSM/scenarios/basic_2_density_discrete_ca.scenario"};
// args = new String[]{"-h"};
try {
Namespace ns = parser.parseArgs(args);
SubCommandRunner sRunner = ns.get("func");
......@@ -39,6 +48,16 @@ public class VadereConsole {
ArgumentParser parser = ArgumentParsers.newArgumentParser("Vadere")
.defaultHelp(true)
.description("Runs the VADERE pedestrian simulator.");
parser.addArgument("--loglevel")
.required(false)
.type(String.class)
.dest("loglevel")
.choices("OFF", "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "ALL")
.setDefault("INFO")
.action(new SetLogLevelCommand())
.help("Set Log Level for vadere.");
Subparsers subparsers = parser.addSubparsers()
.title("subcommands")
.description("valid subcommands")
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.projects.migration.MigrationAssistant;
import org.vadere.simulator.projects.migration.MigrationException;
import org.vadere.simulator.projects.migration.MigrationOptions;
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import org.vadere.util.io.IOUtils;
......
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ScenarioRunSubCommand implements SubCommandRunner{
public class ScenarioRunSubCommand implements SubCommandRunner {
private final static Logger logger = Logger.getLogger(ScenarioRunSubCommand.class);
@Override
......
package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.Argument;
import net.sourceforge.argparse4j.inf.ArgumentAction;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import java.util.Map;
public class SetLogLevelCommand implements ArgumentAction {
@Override
public void run(ArgumentParser parser, Argument arg, Map<String, Object> attrs, String flag, Object value) throws ArgumentParserException {
Level level = Level.toLevel((String) value);
Logger.getRootLogger().setLevel(level);
}
@Override
public void onAttach(Argument arg) {
}
@Override
public boolean consumeArgument() {
return true;
}
}
package org.vadere.simulator.entrypoints;
package org.vadere.simulator.entrypoints.cmd.commands;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.Namespace;
import org.apache.log4j.Logger;
import org.vadere.simulator.entrypoints.ScenarioFactory;
import org.vadere.simulator.entrypoints.cmd.SubCommandRunner;
import org.vadere.simulator.projects.Scenario;
import org.vadere.simulator.projects.ScenarioRun;
import java.nio.file.Path;
import java.nio.file.Paths;
public class SuqSubCommand implements SubCommandRunner{
public class SuqSubCommand implements SubCommandRunner {
private final static Logger logger = Logger.getLogger(SuqSubCommand.class);
@Override
......
......@@ -93,7 +93,7 @@ public class ScenarioRun implements Runnable {
synchronized (scenarioStore) {
logger.info(String.format("Initializing scenario. Start of scenario '%s'...", scenario.getName()));
scenarioStore.getTopography().reset();
System.out.println("StartIt " + scenario.getName());
logger.info("StartIt " + scenario.getName());
MainModelBuilder modelBuilder = new MainModelBuilder(scenarioStore);
modelBuilder.createModelAndRandom();
......
......@@ -5,6 +5,8 @@ import com.fasterxml.jackson.databind.JsonNode;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.vadere.simulator.entrypoints.cmd.SubCommand;
import org.vadere.simulator.entrypoints.cmd.VadereConsole;
import org.vadere.simulator.projects.migration.MigrationAssistant;
import org.vadere.tests.util.reflection.TestJsonNodeExplorer;
import org.vadere.tests.util.reflection.TestJsonNodeHelper;
......
Markdown is supported
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