Stop logging with System.out.println, start using slf4j

This commit is contained in:
P0nk
2022-02-10 21:31:33 +01:00
parent c879e36a9c
commit 2bbfd46105
37 changed files with 227 additions and 160 deletions

View File

@@ -97,6 +97,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.concurrent.TimeUnit.*;
@@ -3587,26 +3588,25 @@ public class Character extends AbstractCharacterObject {
effLock.lock();
chrLock.lock();
try {
System.out.println("-------------------");
System.out.println("CACHED BUFF COUNT: ");
for (Entry<BuffStat, Byte> bpl : buffEffectsCount.entrySet()) {
System.out.println(bpl.getKey() + ": " + bpl.getValue());
}
System.out.println("-------------------");
System.out.println("CACHED BUFFS: ");
for (Entry<Integer, Map<BuffStat, BuffStatValueHolder>> bpl : buffEffects.entrySet()) {
System.out.print(bpl.getKey() + ": ");
for (Entry<BuffStat, BuffStatValueHolder> pble : bpl.getValue().entrySet()) {
System.out.print(pble.getKey().name() + pble.getValue().value + ", ");
}
System.out.println();
}
System.out.println("-------------------");
log.debug("-------------------");
log.debug("CACHED BUFF COUNT: {}", buffEffectsCount.entrySet().stream()
.map(entry -> entry.getKey() + ": " + entry.getValue())
.collect(Collectors.joining(", "))
);
System.out.println("IN ACTION:");
for (Entry<BuffStat, BuffStatValueHolder> bpl : effects.entrySet()) {
System.out.println(bpl.getKey().name() + " -> " + ItemInformationProvider.getInstance().getName(bpl.getValue().effect.getSourceId()));
}
log.debug("-------------------");
log.debug("CACHED BUFFS: {}", buffEffects.entrySet().stream()
.map(entry -> entry.getKey() + ": (" + entry.getValue().entrySet().stream()
.map(innerEntry -> innerEntry.getKey().name() + innerEntry.getValue().value)
.collect(Collectors.joining(", ")) + ")")
.collect(Collectors.joining(", "))
);
log.debug("-------------------");
log.debug("IN ACTION: {}", effects.entrySet().stream()
.map(entry -> entry.getKey().name() + " -> " + ItemInformationProvider.getInstance().getName(entry.getValue().effect.getSourceId()))
.collect(Collectors.joining(", "))
);
} finally {
chrLock.unlock();
effLock.unlock();
@@ -3617,9 +3617,10 @@ public class Character extends AbstractCharacterObject {
effLock.lock();
chrLock.lock();
try {
for (Entry<BuffStat, Byte> mbsl : buffEffectsCount.entrySet()) {
System.out.println(mbsl.getKey().name() + " -> " + mbsl.getValue());
}
log.debug("ALL BUFFS COUNT: {}", buffEffectsCount.entrySet().stream()
.map(entry -> entry.getKey().name() + " -> " + entry.getValue())
.collect(Collectors.joining(", "))
);
} finally {
chrLock.unlock();
effLock.unlock();

View File

@@ -153,7 +153,7 @@ public class CommandsExecutor {
private void addCommand(String syntax, int rank, Class<? extends Command> commandClass) {
if (registeredCommands.containsKey(syntax.toLowerCase())) {
System.out.println("Error on register command with name: " + syntax + ". Already exists.");
log.warn("Error on register command with name: {}. Already exists.", syntax);
return;
}

View File

@@ -25,6 +25,8 @@ import client.Client;
import config.YamlConfig;
import constants.game.ExpTable;
import constants.inventory.ItemConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.ItemInformationProvider;
import tools.PacketCreator;
import tools.Pair;
@@ -36,6 +38,7 @@ import java.util.List;
import java.util.Map;
public class Equip extends Item {
private static final Logger log = LoggerFactory.getLogger(Equip.class);
public enum ScrollResult {
@@ -110,7 +113,7 @@ public class Equip extends Item {
ret.itemLevel = itemLevel;
ret.itemExp = itemExp;
ret.level = level;
ret.log = new LinkedList<>(log);
ret.itemLog = new LinkedList<>(itemLog);
ret.setOwner(getOwner());
ret.setQuantity(getQuantity());
ret.setExpiration(getExpiration());
@@ -647,7 +650,8 @@ public class Equip extends Item {
int expNeeded = ExpTable.getEquipExpNeededForLevel(itemLevel);
if (YamlConfig.config.server.USE_DEBUG_SHOW_INFO_EQPEXP) {
System.out.println("'" + ii.getName(this.getItemId()) + "' -> EXP Gain: " + gain + " Mastery: " + masteryModifier + " Base gain: " + baseExpGain + " exp: " + itemExp + " / " + expNeeded + ", Kills TNL: " + expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
log.debug("{} -> EXP Gain: {}, Mastery: {}, Base gain: {}, exp: {} / {}, Kills TNL: {}", ii.getName(getItemId()),
gain, masteryModifier, baseExpGain, itemExp, expNeeded, expNeeded / (baseExpGain / c.getPlayer().getExpRate()));
}
if (itemExp >= expNeeded) {

View File

@@ -42,7 +42,7 @@ public class Item implements Comparable<Item> {
private int petid = -1;
private Pet pet = null;
private String owner = "";
protected List<String> log;
protected List<String> itemLog;
private short flag;
private long expiration = -1;
private String giftFrom = "";
@@ -51,7 +51,7 @@ public class Item implements Comparable<Item> {
this.id = id;
this.position = position;
this.quantity = quantity;
this.log = new LinkedList<>();
this.itemLog = new LinkedList<>();
this.flag = 0;
}
@@ -67,7 +67,7 @@ public class Item implements Comparable<Item> {
}
this.petid = petid;
this.flag = 0;
this.log = new LinkedList<>();
this.itemLog = new LinkedList<>();
}
public Item copy() {
@@ -75,7 +75,7 @@ public class Item implements Comparable<Item> {
ret.flag = flag;
ret.owner = owner;
ret.expiration = expiration;
ret.log = new LinkedList<>(log);
ret.itemLog = new LinkedList<>(itemLog);
return ret;
}
@@ -147,8 +147,8 @@ public class Item implements Comparable<Item> {
return "Item: " + id + " quantity: " + quantity;
}
public List<String> getLog() {
return Collections.unmodifiableList(log);
public List<String> getItemLog() {
return Collections.unmodifiableList(itemLog);
}
public short getFlag() {