Commit e342b3bb authored by Tien's avatar Tien

Add option to save detail log

parent cd55e85a
/*
* Copyright (C) 2015 tien
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package Logger;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.HashMap;
/**
*
* @author tien
*/
public class Log {
public static String loglocation;
public static String detailloglocation;
// public static String testpath;
public static String logtime;
public void savedetaillog(HashMap<String, HashMap<String, Double>> distant) {
File distantout = new File(detailloglocation + logtime + ".xls");
//File distantout = new File(testpath+"/alldistant.xls");
PrintWriter out;
try {
out = new PrintWriter(distantout);
for (String key : distant.keySet()) {
for (String key2 : distant.get(key).keySet()) {
out.println(key + "\t" + key2 + "\t"
+ distant.get(key).get(key2));
}
}
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void savelog(String conclusion) {
File distantout ;
if (!loglocation.equals("logs/")) {
distantout = new File(loglocation);
} else {
distantout = new File(loglocation+ logtime + ".xls");
}
PrintWriter out;
try {
out = new PrintWriter(distantout);
out.write(conclusion);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
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