Amélioration du système de logging
This commit is contained in:
parent
8b1f18fc1b
commit
ab93d2a773
@ -4,8 +4,10 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class BungeeMain extends Plugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
@Override
|
||||
public void onLoad() {
|
||||
PandacubeUtil.setServerLogger(getProxy().getLogger());
|
||||
PandacubeUtil.setPluginLogger(getLogger());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
33
src/fr/pandacube/java/PandacubeUtil.java
Normal file
33
src/fr/pandacube/java/PandacubeUtil.java
Normal file
@ -0,0 +1,33 @@
|
||||
package fr.pandacube.java;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class PandacubeUtil {
|
||||
|
||||
/**
|
||||
* Représente le logger du serveur Spigot ou de Bungee,selon l'environnement
|
||||
*/
|
||||
private static Logger serverLogger;
|
||||
|
||||
/**
|
||||
* Représente le logger de PandacubeUtil, mais défini selon l'environnement Spigot ou Bungee.
|
||||
*/
|
||||
private static Logger pluginLogger;
|
||||
|
||||
public static Logger getServerLogger() {
|
||||
return serverLogger;
|
||||
}
|
||||
|
||||
public static void setServerLogger(Logger serverLogger) {
|
||||
PandacubeUtil.serverLogger = serverLogger;
|
||||
}
|
||||
|
||||
public static Logger getPluginLogger() {
|
||||
return pluginLogger;
|
||||
}
|
||||
|
||||
public static void setPluginLogger(Logger pluginLogger) {
|
||||
PandacubeUtil.pluginLogger = pluginLogger;
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,8 @@ public class SpigotMain extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
PandacubeUtil.setServerLogger(getServer().getLogger());
|
||||
PandacubeUtil.setPluginLogger(getLogger());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import fr.pandacube.java.PandacubeUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Prends en charge un socket client et le transmet au gestionnaire de paquet correspondant.<br/>
|
||||
@ -41,7 +43,10 @@ public class PacketExecutor implements Runnable {
|
||||
try {
|
||||
rep.sendPacket(new PrintStream(socket.getOutputStream()));
|
||||
} catch (IOException e1) { }
|
||||
e.printStackTrace();
|
||||
if (e instanceof IOException)
|
||||
PandacubeUtil.getPluginLogger().warning("Impossible de lire le packet reçu sur le socket "+socket+" : "+e.toString());
|
||||
else
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user