Added support for varying log levels configurable in the server config (see log_level in default.conf)

Error logs now properly print to stderr when possible
Colour-coded logs
Addressed a scenario in which outgoing packet writes could get hung up
Fixed interface incorrect definition message on server startup
This commit is contained in:
Ceikry
2023-03-01 08:01:14 +00:00
committed by Ryan
parent e1faa64af7
commit 88a2f354b4
171 changed files with 723 additions and 475 deletions
+8 -8
View File
@@ -217,7 +217,7 @@ public class AIPlayer extends Player {
}
}
} catch (FileNotFoundException e) {
System.out.println("Missing " + fileName);
e.printStackTrace();
}
}
@@ -349,7 +349,7 @@ public class AIPlayer extends Player {
int meX = this.getLocation().getX();
int meY = this.getLocation().getY();
//int meX2 = this.getLocation().getX();
//System.out.println("local " + meX + " real x? " + meX2 );
ArrayList<Node> nodes = new ArrayList<Node>();
for (NPC npc : RegionManager.getLocalNpcs(this, range)) {
if (entrys.contains(npc.getId()))
@@ -381,7 +381,7 @@ public class AIPlayer extends Player {
public Node getClosestNodeWithEntryAndDirection(int range, int entry, Direction direction) {
ArrayList<Node> nodeList = getNodeInRange(range, entry);
if (nodeList.isEmpty()) {
//System.out.println("nodelist empty");
return null;
}
Node node = getClosestNodeinNodeListWithDirection(nodeList, direction);
@@ -391,7 +391,7 @@ public class AIPlayer extends Player {
public Node getClosestNodeWithEntry(int range, int entry) {
ArrayList<Node> nodeList = getNodeInRange(range, entry);
if (nodeList.isEmpty()) {
//System.out.println("nodelist empty");
return null;
}
Node node = getClosestNodeinNodeList(nodeList);
@@ -401,7 +401,7 @@ public class AIPlayer extends Player {
public Node getClosestNodeWithEntry(int range, List<Integer> entrys) {
ArrayList<Node> nodeList = getNodeInRange(range, entrys);
if (nodeList.isEmpty()) {
//System.out.println("nodelist empty");
return null;
}
Node node = getClosestNodeinNodeList(nodeList);
@@ -453,7 +453,7 @@ public class AIPlayer extends Player {
private Node getClosestNodeinNodeListWithDirection(ArrayList<Node> nodes, Direction direction) {
if (nodes.isEmpty()) {
//System.out.println("nodelist empty");
return null;
}
@@ -471,7 +471,7 @@ public class AIPlayer extends Player {
private Node getClosestNodeinNodeList(ArrayList<Node> nodes) {
if (nodes.isEmpty()) {
//System.out.println("nodelist empty");
return null;
}
@@ -528,7 +528,7 @@ public class AIPlayer extends Player {
Repository.getPlayers().remove(player);
return;
}
//SystemLogger.logErr(this.getClass(), "Could not deregister AIP#" + uid + ": UID not added to the mapping!");
//log(this.getClass(), Log.ERR, "Could not deregister AIP#" + uid + ": UID not added to the mapping!");
}
@Override
+2 -2
View File
@@ -42,6 +42,7 @@ import core.tools.SystemLogger
import core.game.system.config.ItemConfigParser
import core.game.world.GameWorld
import core.game.world.repository.Repository
import core.tools.Log
import core.tools.colorize
import java.util.*
import java.util.concurrent.CountDownLatch
@@ -78,7 +79,7 @@ class ScriptAPI(private val bot: Player) {
val opt: Option? = node.interaction.options.filter {it != null && it.name.equals(option, true) }.firstOrNull()
if(opt == null){
SystemLogger.logWarn(this::class.java, "Invalid option name provided: $option")
log(this::class.java, Log.WARN, "Invalid option name provided: $option")
return
}
@@ -491,7 +492,6 @@ class ScriptAPI(private val bot: Player) {
}
val canSell = GrandExchange.addBotOffer(actualId, itemAmt)
if (canSell && saleIsBigNews(actualId, itemAmt)) {
SystemLogger.logAI(this::class.java, "Offered $itemAmt of $actualId on the GE.")
Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.")
}
bot.bank.remove(Item(id, itemAmt))