package com.hand.mas.ant.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.PrintWriter;

public class LogUtil {
	private static final String logErrorFile = "error.txt";
	private static final String logWarnFile = "warn.txt";
	
	public static void logError(String log) throws Exception {
		try{
			PrintWriter pw = new PrintWriter(new FileOutputStream(new File(logErrorFile),true));
			pw.println(log);
			pw.close();
		}catch(Exception e){
			throw e;
		}
	}
	
	public static void logWarn(String log) throws Exception {
		try{
			PrintWriter pw = new PrintWriter(new FileOutputStream(new File(logWarnFile),true));
			pw.println(log);
			pw.close();
		}catch(Exception e){
			throw e;
		}
	}
	
	public static void clearLog(){
		try{
			FileWriter fw = new FileWriter(new File(logErrorFile));
			fw.write("");
			fw.flush();
			fw.close();
			FileWriter fw2 = new FileWriter(new File(logWarnFile));
			fw2.write("");
			fw2.flush();
			fw2.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
