Migrate yet another batch of FilePrinter users to Slf4j

One FilePrinter.printError() method removed, one more to go
This commit is contained in:
P0nk
2022-02-09 21:05:22 +01:00
parent 0c60606b4e
commit 8b630f7357
12 changed files with 84 additions and 149 deletions

View File

@@ -63,7 +63,6 @@ import server.expeditions.ExpeditionBossLog;
import server.life.PlayerNPCFactory;
import server.quest.Quest;
import tools.DatabaseConnection;
import tools.FilePrinter;
import tools.Pair;
import java.sql.Connection;
@@ -1106,7 +1105,7 @@ public class Server {
mc.setMGC(mgc);
mgc.setCharacter(mc);
} else {
FilePrinter.printError(FilePrinter.GUILD_CHAR_ERROR, "Could not find " + mc.getName() + " when loading guild " + id + ".");
log.error("Could not find chr {} when loading guild {}", mc.getName(), id);
}
g.setOnline(mc.getId(), true, mc.getClient().getChannel());
@@ -1622,8 +1621,7 @@ public class Server {
delPs.setInt(1, nameChangeId);
delPs.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
FilePrinter.printError(FilePrinter.WORLD_TRANSFER, e, "Failed to delete world transfer for character ID " + characterId);
log.error("Failed to delete world transfer for chrId {}", characterId, e);
}
}
}

View File

@@ -32,8 +32,9 @@ import net.server.coordinator.world.InviteCoordinator;
import net.server.coordinator.world.InviteCoordinator.InviteResult;
import net.server.coordinator.world.InviteCoordinator.InviteResultType;
import net.server.coordinator.world.InviteCoordinator.InviteType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.DatabaseConnection;
import tools.FilePrinter;
import tools.PacketCreator;
import java.sql.Connection;
@@ -45,9 +46,10 @@ import java.sql.SQLException;
* @author Ubaware
*/
public final class AcceptFamilyHandler extends AbstractPacketHandler {
private static final Logger log = LoggerFactory.getLogger(AcceptFamilyHandler.class);
@Override
public final void handlePacket(InPacket p, Client c) {
public void handlePacket(InPacket p, Client c) {
if (!YamlConfig.config.server.USE_FAMILY_SYSTEM) {
return;
}
@@ -134,8 +136,7 @@ public final class AcceptFamilyHandler extends AbstractPacketHandler {
ps.setInt(3, seniorID);
ps.executeUpdate();
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not save new family record for char id " + characterID + ".");
e.printStackTrace();
log.error("Could not save new family record for chrId {}", characterID, e);
}
if (updateChar) {
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET familyid = ? WHERE id = ?")) {
@@ -143,13 +144,11 @@ public final class AcceptFamilyHandler extends AbstractPacketHandler {
ps.setInt(2, characterID);
ps.executeUpdate();
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not update 'characters' 'familyid' record for char id " + characterID + ".");
e.printStackTrace();
log.error("Could not update 'characters' 'familyid' record for chrId {}", characterID, e);
}
}
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
e.printStackTrace();
log.error("Could not get connection to DB while inserting new family record", e);
}
}
}

View File

@@ -35,6 +35,8 @@ import constants.id.ItemId;
import constants.inventory.ItemConstants;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.ItemInformationProvider;
import server.Trade;
import server.maps.*;
@@ -51,6 +53,8 @@ import java.util.Arrays;
* @author Ronan - concurrency safety and reviewed minigames
*/
public final class PlayerInteractionHandler extends AbstractPacketHandler {
private static final Logger log = LoggerFactory.getLogger(PlayerInteractionHandler.class);
public enum Action {
CREATE(0),
INVITE(2),
@@ -550,7 +554,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
}
}
} catch (Exception e) {
FilePrinter.printError(FilePrinter.TRADE_EXCEPTION, e, "Player '" + chr + "' tried to add " + ii.getName(item.getItemId()) + " qty. " + item.getQuantity() + " in trade (slot " + targetSlot + ") then exception occurred.");
log.warn("Chr {} tried to add {}x {} in trade (slot {}), then exception occurred", chr, ii.getName(item.getItemId()), item.getQuantity(), targetSlot, e);
} finally {
inv.unlockInventory();
}

View File

@@ -2,8 +2,9 @@ package net.server.task;
import client.Family;
import net.server.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.DatabaseConnection;
import tools.FilePrinter;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -11,7 +12,7 @@ import java.sql.SQLException;
import java.util.Calendar;
public class FamilyDailyResetTask implements Runnable {
private static final Logger log = LoggerFactory.getLogger(FamilyDailyResetTask.class);
private final World world;
public FamilyDailyResetTask(World world) {
@@ -38,19 +39,16 @@ public class FamilyDailyResetTask implements Runnable {
ps.setLong(1, resetTime.getTimeInMillis());
ps.executeUpdate();
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not reset daily rep for families. On " + Calendar.getInstance().getTime());
e.printStackTrace();
log.error("Could not reset daily rep for families", e);
}
try (PreparedStatement ps = con.prepareStatement("DELETE FROM family_entitlement WHERE timestamp <= ?")) {
ps.setLong(1, resetTime.getTimeInMillis());
ps.executeUpdate();
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not do daily reset for family entitlements. On " + Calendar.getInstance().getTime());
e.printStackTrace();
log.error("Could not do daily reset for family entitlements", e);
}
} catch (SQLException e) {
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not get connection to DB.");
e.printStackTrace();
log.error("Could not get connection to DB", e);
}
}
}