Commit eafe469d authored by Jonathan Shahen's avatar Jonathan Shahen
Browse files

Added parameter to store log files in a particular folder

parent 465f2381
2014/12/11 04:55:32.093-0500,mohawk.MohawkMain,setupUserPreferenceOptions,FINE,[OPTION] Setting the console's maximum width
2014/12/11 04:55:32.109-0500,mohawk.MohawkMain,setupUserPreferenceOptions,FINE,[OPTION] Default Line String Used
2014/12/11 04:55:32.110-0500,mohawk.MohawkMain,setupSmvSpecOptions,FINE,[OPTION] No SMV File included
2014/12/11 04:55:32.110-0500,mohawk.MohawkMain,setupSmvSpecOptions,FINE,[OPTION] Using a specific SPEC File: ./data/testcases/mixed/test1.spec
2014/12/11 04:55:32.110-0500,mohawk.MohawkMain,setupSmvSpecOptions,FINE,[OPTION] Using the default SPEC File Extension: .spec
2014/12/11 04:55:32.110-0500,mohawk.MohawkMain,setupSmvSpecOptions,FINE,[OPTION] Bulk SPEC File inclusion: Disabled
2014/12/11 04:55:32.110-0500,mohawk.MohawkMain,setupResultOptions,INFO,Results File: latestMohawkResults.csv
2014/12/11 04:55:37.509-0500,mohawk.testing.TestingSuite,onlyConvertSpecToSmvFormat,FINE,specFile: ./data/testcases/mixed/test1.spec
......@@ -40,6 +40,7 @@ public class MohawkMain {
// Logger Fields
public final static Logger logger = Logger.getLogger("mohawk");
public static String Logger_filepath = "mohawk.log";
public static String Logger_folderpath = "";
private static ConsoleHandler consoleHandler = new ConsoleHandler();
private static Level LoggerLevel;
private static FileHandler fileHandler;
......@@ -136,6 +137,7 @@ public class MohawkMain {
+ "extra information is given for Verbose; "
+ "default is warning level").hasArg()
.create("loglevel"));
options.addOption(OptionBuilder
.withArgName("logfile|'n'|'u'")
.withDescription(
......@@ -144,7 +146,15 @@ public class MohawkMain {
+ "A unique filename will be created when equal to 'u'; "
+ "default it creates a log called '"
+ Logger_filepath + "'").hasArg()
.create("output"));
.create("logfile"));
options.addOption(OptionBuilder
.withArgName("folderpath")
.withDescription(
"The folderpath where the log file should be created; "
+ "default it creates in the current directory")
.hasArg().create("logfolder"));
options.addOption("noheader", false,
"Does not write the CSV file header to the output log");
......@@ -344,19 +354,36 @@ public class MohawkMain {
if (cmd.hasOption("noheader")) {
WriteCSVFileHeader = false;
}
// Set Logger Folder
if (cmd.hasOption("logfolder")) {
File logfile = new File(cmd.getOptionValue("logfolder"));
if (!logfile.exists()) {
logfile.mkdir();
}
if (logfile.isDirectory()) {
Logger_folderpath = cmd.getOptionValue("logfolder");
} else {
logger.severe("logfolder did not contain a folder that exists or that could be created!");
}
}
// Set File Logger
if (cmd.hasOption("output")) {
if (cmd.hasOption("logfile")) {
// Check if no log file was requested
if (cmd.getOptionValue("output").equals("n")) {
if (cmd.getOptionValue("logfile").equals("n")) {
// Create no log file
Logger_filepath = "";
} else if (cmd.getOptionValue("output").equals("u")) {
} else if (cmd.getOptionValue("logfile").equals("u")) {
// Create a unique log file
Logger_filepath = "mohawk-log.%u.%g.txt";
} else {
try {
// Create a log file with a specific name
File logfile = new File(cmd.getOptionValue("output"));
File logfile = new File(Logger_folderpath + File.separator
+ cmd.getOptionValue("logfile"));
if (!logfile.exists()) {
logfile.createNewFile();
......@@ -380,7 +407,8 @@ public class MohawkMain {
}
// Add Logger File Handler
if (!Logger_filepath.isEmpty()) {
fileHandler = new FileHandler(Logger_filepath);
fileHandler = new FileHandler(Logger_folderpath + File.separator
+ Logger_filepath);
fileHandler.setLevel(getLoggerLevel());
fileHandler.setFormatter(new MohawkCSVFileFormatter());
logger.addHandler(fileHandler);
......
......@@ -13,9 +13,14 @@ import org.junit.Test;
public class RegressionTests {
@Test
public void setup() {
}
@Test
public void runMixedTest3SMV() {
String parameter = "-loglevel debug -rbacspec ./data/testcases/mixed/test3.spec -run smv -smvfile test3.spec.smv";
String parameter = "-loglevel debug -logfile n -rbacspec ./data/testcases/mixed/test3.spec -run smv -smvfile test3.spec.smv";
MohawkResult expectedResult = MohawkResult.GOAL_REACHABLE;
}
......
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