Fixed logger

Fixed crash at boot trying to use logger before creating it
Fixed log formating (moving to FML logger)
This commit is contained in:
LemADEC 2015-08-04 02:54:54 +02:00
parent ad765b41c0
commit eaac754e2e
9 changed files with 24 additions and 23 deletions

View file

@ -156,7 +156,7 @@ public class EntityJump extends Entity {
} }
if (!on) { if (!on) {
WarpDrive.logger.fine(this + " Removing from onUpdate..."); WarpDrive.debugPrint(this + " Removing from onUpdate...");
worldObj.removeEntity(this); worldObj.removeEntity(this);
return; return;
} }
@ -752,7 +752,7 @@ public class EntityJump extends Entity {
+ " blowPoints with massCorrection of " + String.format("%.2f", massCorrection) + " => strength " + " blowPoints with massCorrection of " + String.format("%.2f", massCorrection) + " => strength "
+ String.format("%.2f", collisionStrength)); + String.format("%.2f", collisionStrength));
} else { } else {
WarpDrive.logger.severe("WarpDrive error: unable to compute collision points, ignoring..."); WarpDrive.logger.error("WarpDrive error: unable to compute collision points, ignoring...");
} }
} }

View file

@ -35,6 +35,6 @@ public class LocalProfiler {
long self = (dt - stackElement.internal) / 1000; // in microseconds long self = (dt - stackElement.internal) / 1000; // in microseconds
long total = dt / 1000; long total = dt / 1000;
WarpDrive.logger.fine("Profiling '" + stackElement.name + "': " + (self / 1000.0F) + " ms, total: " + (total / 1000.0F) + " ms"); WarpDrive.logger.info("Profiling '" + stackElement.name + "': " + (self / 1000.0F) + " ms, total: " + (total / 1000.0F) + " ms");
} }
} }

View file

@ -1,7 +1,9 @@
package cr0s.warpdrive; package cr0s.warpdrive;
import java.util.List; import java.util.List;
import java.util.logging.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Level;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -191,26 +193,25 @@ public class WarpDrive implements LoadingCallback {
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
WarpDriveConfig.preInit(new Configuration(event.getSuggestedConfigurationFile())); WarpDriveConfig.preInit(new Configuration(event.getSuggestedConfigurationFile()));
logger = event.getModLog();
if (FMLCommonHandler.instance().getSide().isClient()) { if (FMLCommonHandler.instance().getSide().isClient()) {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
normalFOV = mc.gameSettings.fovSetting; normalFOV = mc.gameSettings.fovSetting;
normalSensitivity = mc.gameSettings.mouseSensitivity; normalSensitivity = mc.gameSettings.mouseSensitivity;
logger.info("[WarpDrive] FOV is " + normalFOV + " Sensitivity is " + normalSensitivity); logger.info("FOV is " + normalFOV + " Sensitivity is " + normalSensitivity);
} }
logger = Logger.getLogger(WarpDrive.MODID, (FMLCommonHandler.instance().getEffectiveSide().isClient() ? "Client " : "Server "));
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
// FIXME FMLInterModComms.sendMessage("Waila", "register", // FIXME FMLInterModComms.sendMessage("Waila", "register", "cr0s.warpdrive.client.WailaHandler.callbackRegister");
// "cr0s.warpdrive.client.WailaHandler.callbackRegister");
} }
public static void debugPrint(String out) { public static void debugPrint(String out) {
if (WarpDriveConfig.G_DEBUGMODE) { if (WarpDriveConfig.G_DEBUGMODE) {
logger.info(out); logger.debug(out);
} }
} }

View file

@ -321,7 +321,7 @@ public class TileEntityMiningLaser extends WarpInterfacedTE {
return isBlock; return isBlock;
} else { } else {
// TODO: implement fluid support through AE or tanks // TODO: implement fluid support through AE or tanks
WarpDrive.logger.severe("Fluids aren't supported yet, ML_DEUTERIUM_MUL_SILKTOUCH should be 0"); WarpDrive.logger.error("Fluids aren't supported yet, ML_DEUTERIUM_MUL_SILKTOUCH should be 0");
} }
} }
} }

View file

@ -762,7 +762,7 @@ public class TileEntityReactor extends WarpEnergyTE {
if (shipVolume < WarpDriveConfig.WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE) { if (shipVolume < WarpDriveConfig.WC_MIN_SHIP_VOLUME_FOR_HYPERSPACE) {
Jumpgate nearestGate = null; Jumpgate nearestGate = null;
if (WarpDrive.jumpgates == null) { if (WarpDrive.jumpgates == null) {
WarpDrive.logger.warning(this + " WarpDrive.instance.jumpGates is NULL!"); WarpDrive.logger.warn(this + " WarpDrive.instance.jumpGates is NULL!");
} else { } else {
nearestGate = WarpDrive.jumpgates.findNearestGate(xCoord, yCoord, zCoord); nearestGate = WarpDrive.jumpgates.findNearestGate(xCoord, yCoord, zCoord);
} }

View file

@ -92,7 +92,7 @@ public class BeamEffectMessage implements IMessage, IMessageHandler<BeamEffectMe
public IMessage onMessage(BeamEffectMessage beamEffectMessage, MessageContext context) { public IMessage onMessage(BeamEffectMessage beamEffectMessage, MessageContext context) {
// skip in case player just logged in // skip in case player just logged in
if (context.getServerHandler().playerEntity.worldObj == null) { if (context.getServerHandler().playerEntity.worldObj == null) {
WarpDrive.logger.severe("WorldObj is null, ignoring beam packet"); WarpDrive.logger.error("WorldObj is null, ignoring beam packet");
return null; return null;
} }

View file

@ -133,7 +133,7 @@ public class CloakMessage implements IMessage, IMessageHandler<CloakMessage, IMe
public IMessage onMessage(CloakMessage cloakMessage, MessageContext context) { public IMessage onMessage(CloakMessage cloakMessage, MessageContext context) {
// skip in case player just logged in // skip in case player just logged in
if (context.getServerHandler().playerEntity.worldObj == null) { if (context.getServerHandler().playerEntity.worldObj == null) {
WarpDrive.logger.severe("WorldObj is null, ignoring cloak packet"); WarpDrive.logger.error("WorldObj is null, ignoring cloak packet");
return null; return null;
} }

View file

@ -64,10 +64,10 @@ public class FrequencyMessage implements IMessage, IMessageHandler<FrequencyMess
} else if (te instanceof TileEntityLaser) { } else if (te instanceof TileEntityLaser) {
((TileEntityLaser) te).setCameraFrequency(frequency); ((TileEntityLaser) te).setCameraFrequency(frequency);
} else { } else {
WarpDrive.logger.warning("Received frequency packet: (" + x + ", " + y + ", " + z + ") is not a valid tile entity"); WarpDrive.logger.warn("Received frequency packet: (" + x + ", " + y + ", " + z + ") is not a valid tile entity");
} }
} else { } else {
WarpDrive.logger.warning("Received frequency packet: (" + x + ", " + y + ", " + z + ") has no tile entity"); WarpDrive.logger.warn("Received frequency packet: (" + x + ", " + y + ", " + z + ") has no tile entity");
} }
} }
@ -75,7 +75,7 @@ public class FrequencyMessage implements IMessage, IMessageHandler<FrequencyMess
public IMessage onMessage(FrequencyMessage frequencyMessage, MessageContext context) { public IMessage onMessage(FrequencyMessage frequencyMessage, MessageContext context) {
// skip in case player just logged in // skip in case player just logged in
if (context.getServerHandler().playerEntity.worldObj == null) { if (context.getServerHandler().playerEntity.worldObj == null) {
WarpDrive.logger.severe("WorldObj is null, ignoring frequency packet"); WarpDrive.logger.error("WorldObj is null, ignoring frequency packet");
return null; return null;
} }

View file

@ -20,11 +20,11 @@ public class ClientCameraUtils {
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
if (parPlayerEntity == null) { if (parPlayerEntity == null) {
WarpDrive.logger.severe("setupViewpoint with null player => denied"); WarpDrive.logger.error("setupViewpoint with null player => denied");
return; return;
} }
if (entityCamera == null) { if (entityCamera == null) {
WarpDrive.logger.severe("setupViewpoint with null camera => denied"); WarpDrive.logger.error("setupViewpoint with null camera => denied");
return; return;
} }
@ -54,7 +54,7 @@ public class ClientCameraUtils {
entityPlayer = null; entityPlayer = null;
WarpDrive.debugPrint("Resetting viewpoint"); WarpDrive.debugPrint("Resetting viewpoint");
} else { } else {
WarpDrive.logger.severe("reseting viewpoint with invalid player entity ?!?"); WarpDrive.logger.error("reseting viewpoint with invalid player entity ?!?");
} }
Keyboard.enableRepeatEvents(false); Keyboard.enableRepeatEvents(false);
@ -73,11 +73,11 @@ public class ClientCameraUtils {
return false; return false;
} }
if (!worldObj.getBlock(check1_x, check1_y, check1_z).isAssociatedBlock(check1_blockId)) { if (!worldObj.getBlock(check1_x, check1_y, check1_z).isAssociatedBlock(check1_blockId)) {
WarpDrive.logger.severe("checking viewpoint, found invalid block1 at (" + check1_x + ", " + check1_y + ", " + check1_z + ")"); WarpDrive.logger.error("checking viewpoint, found invalid block1 at (" + check1_x + ", " + check1_y + ", " + check1_z + ")");
return false; return false;
} }
if (!worldObj.getBlock(check2_x, check2_y, check2_z).isAssociatedBlock(check2_blockId)) { if (!worldObj.getBlock(check2_x, check2_y, check2_z).isAssociatedBlock(check2_blockId)) {
WarpDrive.logger.severe("checking viewpoint, found invalid block2 at (" + check2_x + ", " + check2_y + ", " + check2_z + ")"); WarpDrive.logger.error("checking viewpoint, found invalid block2 at (" + check2_x + ", " + check2_y + ", " + check2_z + ")");
return false; return false;
} }
return true; return true;