Improved stack dump formatting in logs

This commit is contained in:
Unknown 2019-10-18 23:13:29 +02:00 committed by unknown
parent fb9f28eb63
commit 98a7a585bf
48 changed files with 171 additions and 117 deletions

View file

@ -98,7 +98,7 @@ public class Commons {
int.class);
methodThrowable_getStackTraceElement.setAccessible(true);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
@ -367,7 +367,7 @@ public class Commons {
try {
fieldToReturn = clazz.getDeclaredField(obfuscatedName);
} catch (final Exception exception2) {
exception2.printStackTrace();
exception2.printStackTrace(WarpDrive.printStreamError);
final StringBuilder map = new StringBuilder();
for (final Field fieldDeclared : clazz.getDeclaredFields()) {
if (map.length() > 0) {
@ -421,7 +421,7 @@ public class Commons {
try {
saveFolder = world.provider.getSaveFolder();
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
saveFolder = "<Exception DIM" + world.provider.getDimension() + ">";
}
if (saveFolder == null || saveFolder.isEmpty()) {
@ -896,7 +896,7 @@ public class Commons {
new Throwable(), depth + 1);
return stackTraceElement.getMethodName();
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
return "-?-";
}
}
@ -920,7 +920,7 @@ public class Commons {
fileoutputstream.close();
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
@ -942,7 +942,7 @@ public class Commons {
return tagCompound;
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
return null;
@ -1082,7 +1082,7 @@ public class Commons {
exception.getMessage(),
dimensionId));
if (WarpDrive.isDev) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
worldServer = null;
}

View file

@ -0,0 +1,36 @@
package cr0s.warpdrive;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.logging.log4j.Level;
// PrintStream wrapper for the mod logger, useful for exception stack dumps
public class LoggerPrintStream extends PrintStream {
protected final Level level;
public LoggerPrintStream(final Level level) {
super(new OutputStream() {
@Override
public void write(final int b) { }
});
this.level = level;
}
@Override
public void println(final String message)
{
this.logString(message);
}
@Override
public void println(final Object object)
{
this.logString(String.valueOf(object));
}
protected void logString(final String message) {
WarpDrive.logger.log(level, message);
}
}

View file

@ -189,6 +189,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import com.mojang.authlib.GameProfile;
@ -357,6 +358,9 @@ public class WarpDrive {
private static WarpDrivePeripheralHandler peripheralHandler = null;
public static Logger logger;
public static LoggerPrintStream printStreamError;
public static LoggerPrintStream printStreamWarn;
public static LoggerPrintStream printStreamInfo;
public WarpDrive() {
}
@ -364,6 +368,9 @@ public class WarpDrive {
@EventHandler
public void onFMLPreInitialization(@Nonnull final FMLPreInitializationEvent event) {
logger = event.getModLog();
printStreamError = new LoggerPrintStream(Level.ERROR);
printStreamWarn = new LoggerPrintStream(Level.WARN);
printStreamInfo = new LoggerPrintStream(Level.INFO);
WarpDriveConfig.onFMLpreInitialization(event.getModConfigurationDirectory().getAbsolutePath());

View file

@ -249,7 +249,7 @@ public abstract class BlockAbstractContainer extends BlockContainer implements I
WarpDrive.logger.error(String.format("Bad multithreading detected from mod %s %s, please report to mod author",
registryName == null ? blockNeighbor : registryName.getNamespace(),
Commons.format(blockAccess, blockPosUpdated)));
new ConcurrentModificationException().printStackTrace();
new ConcurrentModificationException().printStackTrace(WarpDrive.printStreamError);
}
return;
}

View file

@ -446,7 +446,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
} catch (final Exception exception) {
if ( WarpDriveConfig.LOGGING_LUA
|| Commons.throttleMe("LUA exception") ) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
throw new LuaException(String.format("Internal exception %s from %d:%s to %s.%s(%s)\nCheck server logs for details.",
@ -521,7 +521,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to mount ComputerCraft scripts for %s %s, isFirstTick %s",
peripheralName,
Commons.format(world, pos),
@ -578,7 +578,7 @@ public abstract class TileEntityAbstractInterfaced extends TileEntityAbstractBas
computerAccess.unmount(pathLUA);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to unmount ComputerCraft scripts for %s %s, isFirstTick %s",
peripheralName,
Commons.format(world, pos),

View file

@ -493,9 +493,9 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
hardness = blockState.getBlockHardness(world, blockHit.getBlockPos());
} catch (final Exception exception) {
if (Commons.throttleMe("TileEntityLaser.getBlockHardness")) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Unable to access block hardness value of %s",
blockState.getBlock() ));
exception.printStackTrace();
}
}
if (blockState.getBlock() instanceof IDamageReceiver) {
@ -805,7 +805,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
initiateBeamEmission(newYaw, newPitch);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
return new Object[] { false };
}
return new Object[] { true };
@ -824,7 +824,7 @@ public class TileEntityLaser extends TileEntityAbstractLaser implements IBeamFre
scanResult_blockResistance = -2;
return info;
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
return new Object[] { COMPUTER_ERROR_TAG, 0, 0, 0, null, 0, -3 };
}
} else {

View file

@ -374,7 +374,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
tileEntitiesList.appendTag(tagTileEntity);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
}
@ -626,7 +626,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
lightCamouflage = 0;
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
} else {
blockCamouflage = null;

View file

@ -91,7 +91,7 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser {
try {
isSilkHarvestable = blockState.getBlock().canSilkHarvest(world, blockPos, blockState, null);
} catch (final Exception exception) {// protect in case the mined block is corrupted
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
if (isSilkHarvestable) {
// intended code if AccessTransformer was working with gradlew:
@ -115,7 +115,7 @@ public abstract class TileEntityAbstractMiner extends TileEntityAbstractLaser {
blockState.getBlock().getDrops(itemStackDrops, world, blockPos, blockState, 0);
}
} catch (final Exception exception) {// protect in case the mined block is corrupted
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
return null;
}

View file

@ -126,7 +126,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
indexValuable = 0;
} catch (final Exception exception) {
// not so supposed to happen, so just dump logs for now
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("%s Calculation failed, please report to mod author %s",
this, exception.getMessage() ));
// retry with a slight delay
@ -1089,7 +1089,7 @@ public class TileEntityLaserTreeFarm extends TileEntityAbstractMiner {
blockPosSoils = null;
blockStatePosValuables = null;
if (!(exception instanceof ExceptionChunkNotLoaded)) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("%s Calculation failed for %s",
this, stringTileEntity ));
} else {

View file

@ -90,7 +90,7 @@ public class TileEntityRadar extends TileEntityAbstractEnergyConsumer {
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
}

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.block.energy;
import cr0s.warpdrive.Commons;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.TileEntityAbstractEnergy;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumComponentType;
@ -71,7 +72,9 @@ public class TileEntityCapacitor extends TileEntityAbstractEnergy {
public int energy_getPotentialOutput() {
if (enumTier == null) {
if (Commons.throttleMe("TileEntityCapacitor.notier")) {
new RuntimeException(String.format("%s no tier defined yet, probably an invalid call, please report to mod author", this)).printStackTrace();
new RuntimeException(String.format("%s no tier defined yet, probably an invalid call, please report to mod author",
this ))
.printStackTrace(WarpDrive.printStreamError);
}
return (int) Math.round(energy_getEnergyStored() * getEfficiency());
}

View file

@ -397,7 +397,7 @@ public class TileEntityEnanReactorCore extends TileEntityEnanReactorController {
countLaserMediums = ((TileEntityEnanReactorLaser) tileEntity).laserMedium_getCount();
} catch (final Exception exception) {
if (isFirstException) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
isFirstException = false;
}
WarpDrive.logger.error(String.format("%s tileEntity is %s",

View file

@ -103,7 +103,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
return blockStateCamouflage.getMapColor(blockAccess, blockPos);
} catch (final Exception exception) {
if (!Dictionary.BLOCKS_NOCAMOUFLAGE.contains(blockStateCamouflage.getBlock())) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception trying to get MapColor for %s",
blockStateCamouflage));
Dictionary.BLOCKS_NOCAMOUFLAGE.add(blockStateCamouflage.getBlock());
@ -257,7 +257,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
if (Commons.throttleMe("BlockForceField.getForceFieldSetup")) {
WarpDrive.logger.error(String.format("Exception trying to get force field setup %s",
Commons.format(blockAccess, blockPos) ));
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
}
@ -420,7 +420,7 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
&& Commons.isServerThread() ) {
if (Commons.throttleMe("getExplosionResistance")) {
new RuntimeException(String.format("Invalid call to deprecated getExplosionResistance(%s)",
exploder)).printStackTrace();
exploder )).printStackTrace(WarpDrive.printStreamError);
}
return Float.MAX_VALUE;
}
@ -452,9 +452,9 @@ public class BlockForceField extends BlockAbstractForceField implements IDamageR
}
if (!Commons.isSafeThread()) {
if (isFirstHit) {
WarpDrive.logger.error(String.format("Bad multithreading detected %s from exploder %s explosion %s",
Commons.format(world, blockPos), exploder, explosion ));
new ConcurrentModificationException().printStackTrace();
new ConcurrentModificationException(String.format("Bad multithreading detected %s from exploder %s explosion %s",
Commons.format(world, blockPos), exploder, explosion ))
.printStackTrace(WarpDrive.printStreamError);
} else {
return Float.MAX_VALUE;
}

View file

@ -61,7 +61,7 @@ public class TileEntityForceField extends TileEntity {
cache_lightCamouflage = 0;
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
cache_blockStateCamouflage = null;
cache_colorMultiplierCamouflage = 0;
cache_lightCamouflage = 0;

View file

@ -294,7 +294,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
try {
doScheduledForceFieldRemoval();
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
super.onBlockBroken(world, blockPos, blockState);
}
@ -741,7 +741,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
try {
itemStacks = blockState.getBlock().getDrops(world, vector.getBlockPos(), blockState, 0);
} catch (final Exception exception) {// protect in case the mined block is corrupted
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
itemStacks = null;
}
@ -778,7 +778,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
WarpDrive.logger.info(String.format("%s destroying force field of %d placed out of %d calculated blocks",
this, countPlaced, countCalculated));
if (WarpDriveConfig.LOGGING_FORCE_FIELD) {
new RuntimeException().printStackTrace();
new RuntimeException().printStackTrace(WarpDrive.printStreamInfo);
}
}
@ -1322,7 +1322,7 @@ public class TileEntityForceFieldProjector extends TileEntityAbstractForceField
} catch (final Exception exception) {
vInteriorBlocks = null;
vPerimeterBlocks = null;
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("%s Calculation failed for %s",
this, stringProjector));
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -69,7 +70,7 @@ class JumpGateScanner {
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
return false;
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.block.movement;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.block.BlockSecurityStation;
import cr0s.warpdrive.config.Dictionary;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -81,7 +82,7 @@ class ShipScanner {
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
return false;
}

View file

@ -59,7 +59,7 @@ public class CommandDebug extends AbstractCommand {
metadata = Integer.parseInt(args[5]);
actions = args[6];
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender)));
return;
}

View file

@ -91,7 +91,7 @@ public class CommandEntity extends AbstractCommand {
kill = par.equals("y") || par.equals("yes") || par.equals("1");
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
Commons.addChatMessage(commandSender, new TextComponentString(getUsage(commandSender)));
return;
}

View file

@ -580,7 +580,7 @@ public class WarpDriveConfig {
itemStack.setTagCompound(tagCompound);
} catch (final NBTException exception) {
WarpDrive.logger.error(exception.getMessage());
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Invalid NBT for %s@%d %s",
registryName, meta, stringNBT));
return ItemStack.EMPTY;
@ -619,9 +619,9 @@ public class WarpDriveConfig {
try {
itemStack.setItemDamage(meta);
} catch (final Exception exception) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to get mod item for %s@%d",
registryName, meta));
exception.printStackTrace();
registryName, meta ));
return null;
}
}
@ -1663,7 +1663,7 @@ public class WarpDriveConfig {
IC2_Resin = getItemStackOrFire("ic2:misc_resource", 4);
} catch (final Exception exception) {
WarpDrive.logger.error("Error loading IndustrialCraft2 classes");
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
@ -1673,27 +1673,26 @@ public class WarpDriveConfig {
final ErrorHandler xmlErrorHandler = new ErrorHandler() {
@Override
public void warning(final SAXParseException exception) {
// exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.warn(String.format("XML warning at line %d: %s",
exception.getLineNumber(),
exception.getLocalizedMessage() ));
// exception.printStackTrace();
}
@Override
public void fatalError(final SAXParseException exception) {
// exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.warn(String.format("XML fatal error at line %d: %s",
exception.getLineNumber(),
exception.getLocalizedMessage() ));
// exception.printStackTrace();
}
@Override
public void error(final SAXParseException exception) {
// exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.warn(String.format("XML error at line %d: %s",
exception.getLineNumber(),
exception.getLocalizedMessage() ));
// exception.printStackTrace();
}
};
@ -1706,7 +1705,7 @@ public class WarpDriveConfig {
try {
xmlDocumentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (final ParserConfigurationException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
xmlDocumentBuilder.setErrorHandler(xmlErrorHandler);
}
@ -1753,8 +1752,9 @@ public class WarpDriveConfig {
inputStream.close();
outputStream.close();
} catch (final Exception exception) {
WarpDrive.logger.error(String.format("Failed to unpack resource '%s' into '%s'", resourceName, destination));
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to unpack resource '%s' into '%s'",
resourceName, destination ));
}
}
}

View file

@ -51,9 +51,9 @@ public abstract class XmlFileManager {
parseRootElement(location, element);
}
} catch (final Exception exception) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Error loading file %s: %s",
file.getName(), exception.getMessage()));
exception.printStackTrace();
file.getName(), exception.getMessage() ));
}
}
}

View file

@ -177,7 +177,7 @@ public class XmlPreprocessor {
transformer.transform(input, output);
outputCount.incrementAndGet();
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
}

View file

@ -42,7 +42,7 @@ public class Orb extends AbstractStructure {
orbShells[shellIndexOut].loadFromXmlElement(elementShell);
shellIndexOut++;
} catch (final InvalidXmlException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Skipping invalid shell %s", orbShellName));
}
}
@ -149,7 +149,7 @@ public class Orb extends AbstractStructure {
orbShell.loadFrom(fillerSet);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to instantiate shell %s from structure %s",
name, group));
}

View file

@ -45,7 +45,7 @@ public class Schematic extends AbstractStructure {
replacements[replacementIndexOut].loadFromXmlElement(elementReplacement);
replacementIndexOut++;
} catch (final InvalidXmlException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Skipping invalid replacement %s",
blockState));
}
@ -63,7 +63,7 @@ public class Schematic extends AbstractStructure {
insertions[insertionIndexOut].loadFromXmlElement(elementInsertion);
insertionIndexOut++;
} catch (final InvalidXmlException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Skipping invalid insertion %s",
blockState));
}
@ -144,7 +144,7 @@ public class Schematic extends AbstractStructure {
replacement.loadFrom(fillerSet);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to instantiate replacement %s from structure %s",
name, parentFullName));
}
@ -244,7 +244,7 @@ public class Schematic extends AbstractStructure {
insertion.loadFrom(lootSet);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to instantiate insertion %s from structure %s",
name, parentFullName));
}

View file

@ -565,7 +565,7 @@ public class AcceleratorSetup extends GlobalPosition {
WarpDrive.logger.warn(String.format("%s World is no longer loaded, please report to mod author",
this));
if (Commons.throttleMe("AcceleratorSetup.getCapacitors")) {
new RuntimeException().printStackTrace();
new RuntimeException().printStackTrace(WarpDrive.printStreamWarn);
}
return setTileEntityCapacitors;
}

View file

@ -382,9 +382,9 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
return Math.min(gravity, 1.0D);
}
} catch (final Exception exception) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Invalid gravity value, expecting none, legacySpace, legacyHyperspace, normal or a positive double. Found %s",
stringGravity));
exception.printStackTrace();
stringGravity ));
return 1.0D;
}
}
@ -789,8 +789,9 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
green = Commons.clamp(0.0F, 1.0F, Float.parseFloat(elementColor.getAttribute("green")));
blue = Commons.clamp(0.0F, 1.0F, Float.parseFloat(elementColor.getAttribute("blue")));
} catch (final Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Exception while parsing Color element at %s", location));
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception while parsing Color element at %s",
location ));
red = 0.5F;
green = 0.5F;
blue = 0.5F;
@ -834,9 +835,9 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
blue = Commons.clamp(0.0F, 1.0F, Float.parseFloat(elementRender.getAttribute("blue")));
alpha = Commons.clamp(0.0F, 1.0F, Float.parseFloat(elementRender.getAttribute("alpha")));
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception while parsing Render element RGBA attributes at %s",
location));
location ));
red = 0.5F;
green = 0.5F;
blue = 0.5F;
@ -859,7 +860,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
periodU = Commons.clampMantisse(0.001D, 1000000.0D, Double.parseDouble(stringPeriodU));
} catch (final NumberFormatException exception) {
throw new InvalidXmlException(String.format("Invalid periodU attribute '%s' at %s",
stringPeriodU, location));
stringPeriodU, location ));
}
}
@ -870,7 +871,7 @@ public class CelestialObject implements Cloneable, IStringSerializable, ICelesti
periodV = Commons.clampMantisse(0.001D, 1000000.0D, Double.parseDouble(stringPeriodV));
} catch (final NumberFormatException exception) {
throw new InvalidXmlException(String.format("Invalid periodV attribute '%s' at %s",
stringPeriodV, location));
stringPeriodV, location ));
}
}

View file

@ -67,7 +67,7 @@ public class CloakedArea {
addPlayer(player.getUniqueID());
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}

View file

@ -121,7 +121,7 @@ public class ExtendedProperties {
return byteArrayOutputStream.toByteArray();
} catch (final IOException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception while saving extended properties for entity %s",
entityLivingBase));
}
@ -155,7 +155,7 @@ public class ExtendedProperties {
return true;
} catch (final IOException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception while reading extended properties for entity %s of %d bytes",
entityLivingBase, data.length));
return false;

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.data;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.Dictionary;
import javax.annotation.Nonnull;
@ -44,7 +45,7 @@ public class GravityManager {
classGravityHandler = Class.forName("zmaster587.advancedRocketry.util.GravityHandler");
methodIPlanetaryProvider_applyGravity = classGravityHandler.getMethod("applyGravity", Entity.class);
} catch (final ClassNotFoundException | NoSuchMethodException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
classGravityHandler = null;
}
}
@ -53,7 +54,7 @@ public class GravityManager {
try {
methodIPlanetaryProvider_applyGravity.invoke(null, entityItem);
} catch (final InvocationTargetException | IllegalAccessException exception) {// report and prevent further calls
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
classGravityHandler = null;
}
return;

View file

@ -413,7 +413,7 @@ public class JumpBlock {
return target;
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Deploy failed from (%d %d %d) of %s:%d",
x, y, z, block, blockMeta));
}
@ -454,9 +454,9 @@ public class JumpBlock {
}
}
} catch (final Exception exception) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.info(String.format("Exception involving TileEntity %s %s",
className, Commons.format(world, blockPos)));
exception.printStackTrace();
}
}
}

View file

@ -597,7 +597,7 @@ public class JumpShip {
}
actualMass = newMass;
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
final WarpDriveText textComponent = new WarpDriveText(Commons.getStyleWarning(), "warpdrive.ship.guide.save_exception",
Commons.format(world, blockPos));
WarpDrive.logger.error(textComponent.getUnformattedText());

View file

@ -352,7 +352,7 @@ public class StarMapRegistry {
try {
return Integer.parseInt(stringDimension);
} catch (final Exception exception) {
// exception.printStackTrace();
// exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.info(String.format("Invalid dimension %s, expecting integer or overworld/nether/end/theend/space/hyper/hyperspace",
stringDimension));
}
@ -543,9 +543,9 @@ public class StarMapRegistry {
isLoaded = chunk != null && chunk.isLoaded();
} catch (final NoSuchFieldError exception) {
if (!isExceptionReported) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.info(String.format("Unable to check non-loaded chunks for star map entry %s",
registryItem));
exception.printStackTrace();
isExceptionReported = true;
}
isLoaded = chunkProviderServer.chunkExists(registryItem.x >> 4, registryItem.z >> 4);

View file

@ -394,12 +394,12 @@ public class ChunkHandler {
}
} catch (final ConcurrentModificationException exception) {
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("%s world %s had some chunks changed outside main thread? (size %d -> %d, loaded %d, removed %d, index 0x%X x %d z %d)",
world.isRemote ? "Client" : "Server",
Commons.format(world),
sizeBefore, mapRegistryItems.size(), countLoaded, countRemoved,
indexCurrent, indexCurrent & 0xFFFFFFFFL, (indexCurrent >> 32) & 0xFFFFFFFFL));
exception.printStackTrace();
indexCurrent, indexCurrent & 0xFFFFFFFFL, (indexCurrent >> 32) & 0xFFFFFFFFL ));
LocalProfiler.printCallStats();
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.event;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.GenericSet;
import cr0s.warpdrive.data.CelestialObjectManager;
import cr0s.warpdrive.config.WarpDriveConfig;
@ -47,7 +48,7 @@ public class CommonWorldGenerator implements IWorldGenerator {
structureGroup.generate(world, random, x, y, z);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}

View file

@ -586,7 +586,7 @@ public class JumpSequencer extends AbstractSequencer {
WarpDrive.logger.info(this + " Saving ship state prior to jump in " + schematicFileName);
Commons.writeNBTToFile(schematicFileName, schematic);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
msCounter = System.currentTimeMillis();
@ -1182,11 +1182,11 @@ public class JumpSequencer extends AbstractSequencer {
}
}
} catch (final Exception exception) {
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
exception.printStackTrace(WarpDrive.printStreamError);
}
WarpDrive.logger.info(String.format("Exception while moving external %s@%d at (%d %d %d)",
jumpBlock.block, jumpBlock.blockMeta, jumpBlock.x, jumpBlock.y, jumpBlock.z));
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
exception.printStackTrace();
}
}
index++;
}
@ -1306,11 +1306,11 @@ public class JumpSequencer extends AbstractSequencer {
}
}
} catch (final Exception exception) {
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
exception.printStackTrace(WarpDrive.printStreamError);
}
WarpDrive.logger.info(String.format("Exception while removing %s@%d at (%d %d %d)",
jumpBlock.block, jumpBlock.blockMeta, jumpBlock.x, jumpBlock.y, jumpBlock.z));
if (WarpDriveConfig.LOGGING_JUMPBLOCKS) {
exception.printStackTrace();
}
}
}
@ -1346,8 +1346,9 @@ public class JumpSequencer extends AbstractSequencer {
removeDuplicates(worldTarget.loadedTileEntityList);
} catch (final Exception exception) {
if (WarpDriveConfig.LOGGING_JUMP) {
WarpDrive.logger.info(String.format("Exception while checking for TE duplicates: %s", exception.getMessage()));
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.info(String.format("Exception while checking for TE duplicates: %s",
exception.getMessage() ));
}
}

View file

@ -281,7 +281,7 @@ public class LivingHandler {
player_cloakTicks.put(player.getUniqueID(), cloakTicks + 1);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}

View file

@ -45,7 +45,7 @@ public class ModelBakeEventHandler {
bakedModelNew.setModelResourceLocation(entry.getKey());
bakedModelNew.setOriginalBakedModel(bakedModelExisting);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to update baked model through %s of %s",
entry.getKey(), entry.getValue()));
continue;

View file

@ -401,10 +401,10 @@ public class TooltipHandler {
block.getRegistryName(),
metadata,
throwable1 ));
throwable1.printStackTrace();
throwable1.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("followed by %s",
throwable2 ));
throwable2.printStackTrace();
throwable2.printStackTrace(WarpDrive.printStreamError);
// Final fallback to default
blockState = block.getDefaultState();
}

View file

@ -65,8 +65,9 @@ public class MessageClientSync implements IMessage, IMessageHandler<MessageClien
Dictionary.ITEMS_FLYINSPACE = Dictionary.readItemsFromNBT(messageClientSync.tagCompound.getTagList("items_flyInSpace" , NBT.TAG_STRING));
Dictionary.ITEMS_NOFALLDAMAGE = Dictionary.readItemsFromNBT(messageClientSync.tagCompound.getTagList("items_noFallDamage" , NBT.TAG_STRING));
} catch (final Exception exception) {
exception.printStackTrace();
WarpDrive.logger.error(String.format("Fails to parse client synchronization packet %s", messageClientSync.tagCompound));
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Fails to parse client synchronization packet %s",
messageClientSync.tagCompound ));
}
return new MessageClientValidation();

View file

@ -54,7 +54,7 @@ public class MessageClientValidation implements IMessage, IMessageHandler<Messag
printWriter.close();
}
} catch (final IOException exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error("Exception while saving client validation to disk");
}
}

View file

@ -216,7 +216,7 @@ public class PacketHandler {
try {
return (Packet) EntityTrackerEntry_getPacketForThisEntity.invoke(entry);
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
WarpDrive.logger.error(String.format("Unable to get packet for entity %s",
entity));
@ -287,7 +287,7 @@ public class PacketHandler {
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
}
}

View file

@ -68,7 +68,7 @@ public abstract class BakedModelAbstractBase implements IMyBakedModel {
}
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception trying to retrieve format for %s original baked model %s, defaulting to forge",
modelResourceLocation, bakedModelOriginal));
format = DefaultVertexFormats.ITEM;

View file

@ -40,7 +40,7 @@ public class BakedModelCamouflage extends BakedModelAbstractBase {
final IBakedModel bakedModelResult = blockModelShapes.getModelForState(blockStateReference);
return bakedModelResult.getQuads(blockStateReference, enumFacing, rand);
} catch(final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Failed to render camouflage for block state %s, updating dictionary with %s = NOCAMOUFLAGE dictionary to prevent further errors",
blockStateReference,
blockStateReference.getBlock().getRegistryName()));

View file

@ -58,9 +58,9 @@ public class BakedModelCapacitor extends BakedModelAbstractBase {
final EnumDisabledInputOutput enumDisabledInputOutput = getEnumDisabledInputOutput(extendedBlockState, enumFacing);
if (enumDisabledInputOutput == null) {
if (Commons.throttleMe("BakedModelCapacitor invalid extended")) {
new RuntimeException("Invalid extended property").printStackTrace();
WarpDrive.logger.error(String.format("%s Invalid extended property for %s enumFacing %s\n%s",
this, extendedBlockState, enumFacing, formatDetails()));
new RuntimeException(String.format("%s Invalid extended property for %s enumFacing %s\n%s",
this, extendedBlockState, enumFacing, formatDetails() ))
.printStackTrace(WarpDrive.printStreamError);
}
return getDefaultQuads(enumFacing, rand);
}

View file

@ -42,9 +42,9 @@ public class BakedModelOmnipanel extends BakedModelAbstractBase {
if (extendedBlockStateDefault == null) {
if (!(blockStateDefault instanceof IExtendedBlockState)) {
if (Commons.throttleMe("BakedModelOmnipanel Invalid default")) {
WarpDrive.logger.error(String.format("Invalid default blockstate %s for model %s",
blockStateDefault, modelResourceLocation));
(new RuntimeException()).printStackTrace();
new RuntimeException(String.format("Invalid default blockstate %s for model %s",
blockStateDefault, modelResourceLocation ))
.printStackTrace(WarpDrive.printStreamError);
}
return bakedModelOriginal.getQuads(null, enumFacing, rand);
}
@ -74,17 +74,17 @@ public class BakedModelOmnipanel extends BakedModelAbstractBase {
} else if (!(blockState instanceof IExtendedBlockState)) {
if (Commons.throttleMe("BakedModelOmnipanel Invalid non-extended")) {
WarpDrive.logger.error(String.format("Invalid non-extended blockstate %s for model %s",
blockStateDefault, modelResourceLocation));
(new RuntimeException()).printStackTrace();
new RuntimeException(String.format("Invalid non-extended blockstate %s for model %s",
blockStateDefault, modelResourceLocation ))
.printStackTrace(WarpDrive.printStreamError);
}
return bakedModelOriginal.getQuads(null, enumFacing, rand);
} else {// it's an extended state without values
if (Commons.throttleMe("BakedModelOmnipanel Invalid extended")) {
WarpDrive.logger.error(String.format("Invalid extended blockstate %s for model %s",
blockStateDefault, modelResourceLocation));
(new RuntimeException()).printStackTrace();
new RuntimeException(String.format("Invalid extended blockstate %s for model %s",
blockStateDefault, modelResourceLocation ))
.printStackTrace(WarpDrive.printStreamError);
}
extendedBlockState = extendedBlockStateDefault;

View file

@ -118,9 +118,9 @@ public enum CustomModelLoaderProjector implements ICustomModelLoader {
EnumForceFieldShape enumForceFieldShape = exState != null ? exState.getValue(BlockForceFieldProjector.SHAPE) : EnumForceFieldShape.NONE;
if (enumForceFieldShape == null) {
if (Commons.throttleMe("CustomModelLoaderProjector Invalid shape")) {
new RuntimeException("Invalid shape").printStackTrace();
WarpDrive.logger.error(String.format("Invalid shape for %s facing %s",
blockState, enumFacing));
new RuntimeException(String.format("Invalid shape for %s facing %s",
blockState, enumFacing ))
.printStackTrace(WarpDrive.printStreamError);
}
enumForceFieldShape = EnumForceFieldShape.NONE;
}

View file

@ -1,5 +1,6 @@
package cr0s.warpdrive.render;
import cr0s.warpdrive.WarpDrive;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.EnumCameraType;
@ -78,7 +79,7 @@ public class RenderOverlayCamera {
0xFF008F, true);
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
}
GlStateManager.depthMask(true);

View file

@ -276,7 +276,7 @@ public class WorldGenStructure {
inventory ));
}
} catch (final Exception exception) {
exception.printStackTrace();
exception.printStackTrace(WarpDrive.printStreamError);
WarpDrive.logger.error(String.format("Exception while filling inventory with LootSet %s %s: loot %s from %s in slot %d of inventory %s reported %s",
group,
Commons.format(world, blockPos),