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) {
e.printStackTrace();//For those who get errors
log.error("[SEVERE] Syntax error in 'world.ini'.");
log.error("[SEVERE] Syntax error in 'world.ini'.", e); //For those who get errors
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.world.Party;
import net.server.world.PartyCharacter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.AbstractPlayerInteraction;
import scripting.event.scheduler.EventScriptScheduler;
import server.ItemInformationProvider;
@@ -56,8 +58,6 @@ import java.awt.*;
import java.util.List;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import java.util.logging.Level;
import java.util.logging.Logger;
import static java.util.concurrent.TimeUnit.MINUTES;
@@ -66,6 +66,7 @@ import static java.util.concurrent.TimeUnit.MINUTES;
* @author Ronan
*/
public class EventInstanceManager {
private static final Logger log = LoggerFactory.getLogger(EventInstanceManager.class);
private final Map<Integer, Character> chars = new HashMap<>();
private int leaderId = -1;
private final List<Monster> mobs = new LinkedList<>();
@@ -298,7 +299,7 @@ public class EventInstanceManager {
try {
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
} 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);
}
@@ -315,7 +316,7 @@ public class EventInstanceManager {
try {
invokeScriptFunction("scheduledTimeout", EventInstanceManager.this);
} 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);
}
@@ -387,7 +388,7 @@ public class EventInstanceManager {
try {
invokeScriptFunction("playerUnregistered", EventInstanceManager.this, chr);
} 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();

View File

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