Logging clean-up
Small commit towards improving the file log system.
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.Calendar;
|
||||
public class FilePrinter {
|
||||
|
||||
public static final String
|
||||
ACCOUNT_STUCK = "accountStuck.txt",
|
||||
ACCOUNT_STUCK = "accountStuck.txt",
|
||||
EXCEPTION_CAUGHT = "exceptionCaught.txt",
|
||||
CLIENT_START = "clientStartError.txt",
|
||||
ADD_PLAYER = "addPlayer.txt",
|
||||
@@ -39,11 +39,13 @@ public class FilePrinter {
|
||||
PACKET_LOGS = "packetlogs/",
|
||||
DELETED_CHARACTERS = "deletedchars/",
|
||||
FREDRICK = "fredrick/",
|
||||
NPC_UNCODED = "uncodedNPCs.txt",
|
||||
QUEST_UNCODED = "uncodedQuests.txt",
|
||||
SAVING_CHARACTER = "saveChar.txt";//more to come (maps)
|
||||
NPC_UNCODED = "uncodedNPCs.txt",
|
||||
QUEST_UNCODED = "uncodedQuests.txt",
|
||||
SAVING_CHARACTER = "saveChar.txt",
|
||||
USED_COMMANDS = "usedCommands.txt";//more to come (maps)
|
||||
|
||||
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //for file system purposes, it's nice to use yyyy-MM-dd
|
||||
private static final String FILE_PATH = "logs/" + sdf.format(Calendar.getInstance().getTime()) + "/";// + sdf.format(Calendar.getInstance().getTime()) + "/"
|
||||
private static final String FILE_PATH = "logs/" + sdf.format(Calendar.getInstance().getTime()) + "/"; // + sdf.format(Calendar.getInstance().getTime()) + "/"
|
||||
private static final String ERROR = "error/";
|
||||
|
||||
public static void printError(final String name, final Throwable t) {
|
||||
@@ -130,7 +132,7 @@ public class FilePrinter {
|
||||
}
|
||||
|
||||
public static void print(final String name, final String s, boolean line) {
|
||||
System.out.println("Error thrown: " + name);
|
||||
System.out.println("Log: " + name);
|
||||
System.out.println(s);
|
||||
FileOutputStream out = null;
|
||||
String file = FILE_PATH + name;
|
||||
|
||||
@@ -60,14 +60,14 @@ public class LogHelper {
|
||||
}
|
||||
|
||||
public static void logLeaf(MapleCharacter player, boolean gotPrize, String operation) {
|
||||
String timeStamp = new SimpleDateFormat("dd-M-yyyy hh:mm:ss").format(new Date());
|
||||
String timeStamp = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
|
||||
String log = player.getName() + (gotPrize ? " used a maple leaf to buy " + operation : " redeemed " + operation + " VP for a leaf") + " - " + timeStamp + "\r\n";
|
||||
FilePrinter.printError("mapleleaves.txt", log);
|
||||
}
|
||||
|
||||
public static void logGacha(MapleCharacter player, int itemid, String map) {
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(itemid);
|
||||
String timeStamp = new SimpleDateFormat("dd-M-yyyy hh:mm:ss").format(new Date());
|
||||
String timeStamp = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date());
|
||||
String log = player.getName() + " got a " + itemName + "(" + itemid + ") from the " + map + " gachapon. - " + timeStamp + "\r\n";
|
||||
FilePrinter.printError("gachapon.txt", log);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user