Logging clean-up

Small commit towards improving the file log system.
This commit is contained in:
ronancpl
2017-05-19 20:07:33 -03:00
parent 36c3b7dea8
commit cb49edc3cd
7 changed files with 20 additions and 13 deletions

View File

@@ -354,8 +354,9 @@ public class Commands {
player.yellowMessage("SourMjolk - Game Master");
player.yellowMessage("Kanade - Game Master");
player.yellowMessage("Kitsune - Game Master");
player.yellowMessage("Branch Staff");
player.yellowMessage("MapleSolaxiaV2 Staff");
player.yellowMessage("Ronan - Freelance Developer");
player.yellowMessage("Vcoc - Freelance Developer");
break;
case "lastrestart":
case "uptime":

View File

@@ -29,6 +29,8 @@ import client.MapleCharacter;
import client.MapleClient;
import client.autoban.AutobanFactory;
import client.command.Commands;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public final class GeneralChatHandler extends net.AbstractMaplePacketHandler {
@@ -57,7 +59,9 @@ public final class GeneralChatHandler extends net.AbstractMaplePacketHandler {
for (String used : sp) {
command += used + " ";
}
FilePrinter.printError("usedCommands.txt", c.getPlayer().getName() + " used: " + heading + command + "\r\n");
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm");
FilePrinter.print(FilePrinter.USED_COMMANDS + ".txt", c.getPlayer().getName() + " used: " + heading + command + "on " + sdf.format(Calendar.getInstance().getTime()) + "\r\n");
}
}
} else {

View File

@@ -110,7 +110,7 @@ public final class TakeDamageHandler extends AbstractMaplePacketHandler {
}
} catch(ClassCastException e) {
e.printStackTrace();
FilePrinter.print(FilePrinter.EXCEPTION_CAUGHT, "Attacker is not a mob-type, rather is a " + map.getMapObject(oid).getClass().getName() + " entity.");
FilePrinter.printError(FilePrinter.EXCEPTION_CAUGHT, "Attacker is not a mob-type, rather is a " + map.getMapObject(oid).getClass().getName() + " entity.");
}
direction = slea.readByte();

View File

@@ -213,7 +213,7 @@ public class MapleInventoryManipulator {
}
c.announce(MaplePacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, item))));
} else {
FilePrinter.print(FilePrinter.ITEM, "Tried to pickup Equip id " + item.getItemId() + " containing more than 1 quantity --> " + quantity);
FilePrinter.printError(FilePrinter.ITEM, "Tried to pickup Equip id " + item.getItemId() + " containing more than 1 quantity --> " + quantity);
c.announce(MaplePacketCreator.getInventoryFull());
c.announce(MaplePacketCreator.showItemUnavailable());
return false;

View File

@@ -107,7 +107,7 @@ public class PartyQuest {
} else if(PQ.equals("LudiPQLast")) {
return 800 * level / 5;
}
FilePrinter.print(FilePrinter.NPC, "Unhandled PartyQuest: " + PQ);
FilePrinter.printError(FilePrinter.NPC, "Unhandled PartyQuest: " + PQ);
return 0;
}
}

View File

@@ -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;

View File

@@ -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);
}