+Added Log File Output
Changed Log to output to a file
This commit is contained in:
@@ -53,6 +53,7 @@ public class KittyRP
|
||||
while(!log.isEmpty())
|
||||
{
|
||||
writer.println(log.get(0));
|
||||
writer.flush();
|
||||
log.remove(0);
|
||||
}
|
||||
writer.close();
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Main extends ListenerAdapter
|
||||
public static void main(String[] args) throws InterruptedException, LoginException, Exception
|
||||
{
|
||||
// Factory startup. The ordering is intentional.
|
||||
GlobalLog.initialize();
|
||||
databaseManager = ObjectBuilderFactory.ConstructDatabaseManager();
|
||||
commandEnabler = ObjectBuilderFactory.ConstructCommandEnabler();
|
||||
commandManager = ObjectBuilderFactory.ConstructCommandManager(commandEnabler);
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
package utils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
public class GlobalLog
|
||||
{
|
||||
private static final String log = "Log";
|
||||
private static final String warn = "Warning";
|
||||
private static final String error = "ERROR";
|
||||
private static final String fatal = "FATAL";
|
||||
private static PrintWriter outputLog;
|
||||
|
||||
public static void initialize() throws FileNotFoundException, UnsupportedEncodingException
|
||||
{
|
||||
outputLog = new PrintWriter("OutputLog.txt", "UTF-8");
|
||||
}
|
||||
|
||||
private static void Write(String status, LogFilter filter, String body)
|
||||
{
|
||||
System.out.println("[" + status + "] " + "[" + filter.name() + "] " + body);
|
||||
String logLine = "[" + status + "] " + "[" + filter.name() + "] " + body;
|
||||
outputLog.write(logLine + "\n");
|
||||
outputLog.flush();
|
||||
System.out.println(logLine);
|
||||
}
|
||||
|
||||
public static void Log(String msg) { Write(log, LogFilter.Debug, msg); }
|
||||
|
||||
Reference in New Issue
Block a user