Stop using java.util.logging.Logger, start using slf4j

This commit is contained in:
P0nk
2022-02-10 21:47:37 +01:00
parent 2bbfd46105
commit aceb410331
3 changed files with 19 additions and 18 deletions

View File

@@ -884,8 +884,7 @@ public class Server {
} }
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();//For those who get errors log.error("[SEVERE] Syntax error in 'world.ini'.", e); //For those who get errors
log.error("[SEVERE] Syntax error in 'world.ini'.");
System.exit(0); System.exit(0);
} }

View File

@@ -34,6 +34,8 @@ import net.server.audit.locks.factory.MonitoredWriteLockFactory;
import net.server.coordinator.world.EventRecallCoordinator; import net.server.coordinator.world.EventRecallCoordinator;
import net.server.world.Party; import net.server.world.Party;
import net.server.world.PartyCharacter; import net.server.world.PartyCharacter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.AbstractPlayerInteraction; import scripting.AbstractPlayerInteraction;
import scripting.event.scheduler.EventScriptScheduler; import scripting.event.scheduler.EventScriptScheduler;
import server.ItemInformationProvider; import server.ItemInformationProvider;
@@ -56,8 +58,6 @@ import java.awt.*;
import java.util.List; import java.util.List;
import java.util.*; import java.util.*;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.MINUTES;
@@ -66,6 +66,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
* @author Ronan * @author Ronan
*/ */
public class EventInstanceManager { public class EventInstanceManager {
private static final Logger log = LoggerFactory.getLogger(EventInstanceManager.class);
private final Map<Integer, Character> chars = new HashMap<>(); private final Map<Integer, Character> chars = new HashMap<>();
private int leaderId = -1; private int leaderId = -1;
private final List<Monster> mobs = new LinkedList<>(); private final List<Monster> mobs = new LinkedList<>();
@@ -298,7 +299,7 @@ public class EventInstanceManager {
try { try {
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this); invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement scheduledTimeout function.", ex); log.error("Event script {} does not implement the scheduledTimeout function", em.getName(), ex);
} }
}, time); }, time);
} }
@@ -315,7 +316,7 @@ public class EventInstanceManager {
try { try {
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this); invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement scheduledTimeout function.", ex); log.error("Event script {} does not implement the scheduledTimeout function", em.getName(), ex);
} }
}, nextTime); }, nextTime);
} }
@@ -387,7 +388,7 @@ public class EventInstanceManager {
try { try {
invokeScriptFunction("playerUnregistered", EventInstanceManager.this, chr); invokeScriptFunction("playerUnregistered", EventInstanceManager.this, chr);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, "Event '" + em.getName() + "' does not implement playerUnregistered function.", ex); log.error("Event script {} does not implement the playerUnregistered function", em.getName(), ex);
} }
wL.lock(); wL.lock();

View File

@@ -34,6 +34,8 @@ import net.server.guild.Guild;
import net.server.world.Party; import net.server.world.Party;
import net.server.world.PartyCharacter; import net.server.world.PartyCharacter;
import net.server.world.World; import net.server.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.event.scheduler.EventScriptScheduler; import scripting.event.scheduler.EventScriptScheduler;
import server.Marriage; import server.Marriage;
import server.ThreadManager; import server.ThreadManager;
@@ -48,8 +50,6 @@ import javax.script.Invocable;
import javax.script.ScriptException; import javax.script.ScriptException;
import java.util.*; import java.util.*;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
@@ -60,6 +60,7 @@ import static java.util.concurrent.TimeUnit.SECONDS;
* @author Ronan * @author Ronan
*/ */
public class EventManager { public class EventManager {
private static final Logger log = LoggerFactory.getLogger(EventManager.class);
private Invocable iv; private Invocable iv;
private Channel cserv; private Channel cserv;
private World wserv; private World wserv;
@@ -183,7 +184,7 @@ public class EventManager {
try { try {
iv.invokeFunction(methodName, eim); iv.invokeFunction(methodName, eim);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script schedule", ex);
} }
}; };
@@ -198,7 +199,7 @@ public class EventManager {
try { try {
iv.invokeFunction(methodName, (Object) null); iv.invokeFunction(methodName, (Object) null);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script scheduleAtTimestamp", ex);
} }
}; };
@@ -432,7 +433,7 @@ public class EventManager {
eim.startEvent(); eim.startEvent();
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script startInstance", ex);
} }
return true; return true;
@@ -504,7 +505,7 @@ public class EventManager {
eim.startEvent(); eim.startEvent();
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script startInstance", ex);
} }
return true; return true;
@@ -576,7 +577,7 @@ public class EventManager {
eim.startEvent(); eim.startEvent();
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script startInstance", ex);
} }
return true; return true;
@@ -648,7 +649,7 @@ public class EventManager {
eim.startEvent(); eim.startEvent();
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script startInstance", ex);
} }
return true; return true;
@@ -715,7 +716,7 @@ public class EventManager {
eim.startEvent(); eim.startEvent();
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script startInstance", ex);
} }
return true; return true;
@@ -755,7 +756,7 @@ public class EventManager {
try { try {
iv.invokeFunction("clearPQ", eim); iv.invokeFunction("clearPQ", eim);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script clearPQ", ex);
} }
} }
@@ -763,7 +764,7 @@ public class EventManager {
try { try {
iv.invokeFunction("clearPQ", eim, toMap); iv.invokeFunction("clearPQ", eim, toMap);
} catch (ScriptException | NoSuchMethodException ex) { } catch (ScriptException | NoSuchMethodException ex) {
Logger.getLogger(EventManager.class.getName()).log(Level.SEVERE, null, ex); log.error("Event script clearPQ", ex);
} }
} }