From 14187dc79922dbdb66f52c75cc3e3651382236a6 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Fri, 4 Jul 2014 17:43:53 -0500 Subject: [PATCH] Added Packet Logging Added Crafting Logging --- core/AELog.java | 9 +++++++++ core/features/AEFeature.java | 2 +- core/sync/AppEngPacket.java | 10 +++++++++- crafting/CraftingJob.java | 14 +++++++------- crafting/MECraftingInventory.java | 4 ---- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/core/AELog.java b/core/AELog.java index 743d024e..fc3d6519 100644 --- a/core/AELog.java +++ b/core/AELog.java @@ -70,4 +70,13 @@ public class AELog info( aeBaseTile.getClass().getName() + " @ " + xCoord + ", " + yCoord + ", " + zCoord ); } } + + public static void crafting(String format, Object... data) + { + if ( AEConfig.instance.isFeatureEnabled( AEFeature.CraftingLog ) ) + { + log( Level.INFO, format, data ); + } + } + } diff --git a/core/features/AEFeature.java b/core/features/AEFeature.java index 6ff60a7f..0aebe004 100644 --- a/core/features/AEFeature.java +++ b/core/features/AEFeature.java @@ -52,7 +52,7 @@ public enum AEFeature enableFacadeCrafting("Crafting"), inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false), - AlphaPass("Rendering"), PaintBalls("Tools"); + AlphaPass("Rendering"), PaintBalls("Tools"), PacketLogging("Misc", false), CraftingLog("Misc", false); String Category; boolean visible = true; diff --git a/core/sync/AppEngPacket.java b/core/sync/AppEngPacket.java index 68ce83b1..e5ddcc93 100644 --- a/core/sync/AppEngPacket.java +++ b/core/sync/AppEngPacket.java @@ -2,6 +2,9 @@ package appeng.core.sync; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; +import appeng.core.AEConfig; +import appeng.core.AELog; +import appeng.core.features.AEFeature; import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.NetworkHandler; import cpw.mods.fml.common.network.internal.FMLProxyPacket; @@ -39,7 +42,12 @@ public abstract class AppEngPacket if ( p.array().length > 2 * 1024 * 1024 ) // 2k walking room :) throw new IllegalArgumentException( "Sorry AE2 made a " + p.array().length + " byte packet by accident!" ); - return new FMLProxyPacket( p, NetworkHandler.instance.getChannel() ); + FMLProxyPacket pp = new FMLProxyPacket( p, NetworkHandler.instance.getChannel() ); + + if ( AEConfig.instance.isFeatureEnabled( AEFeature.PacketLogging ) ) + AELog.info( getClass().getName() + " : " + pp.payload().readableBytes() ); + + return pp; } } diff --git a/crafting/CraftingJob.java b/crafting/CraftingJob.java index 6e21999d..d3b8c8d4 100644 --- a/crafting/CraftingJob.java +++ b/crafting/CraftingJob.java @@ -158,10 +158,10 @@ public class CraftingJob implements Runnable, ICraftingJob for (String s : opsAndMultiplier.keySet()) { twoIntegers ti = opsAndMultiplier.get( s ); - AELog.info( s + " * " + ti.times + " = " + (ti.perOp * ti.times) ); + AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) ); } - AELog.info( "------------- " + getByteTotal() + "b real" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" ); + AELog.crafting( "------------- " + getByteTotal() + "b real" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" ); // if ( mode == Actionable.MODULATE ) // meci.moveItemsToStorage( storage ); } @@ -182,10 +182,10 @@ public class CraftingJob implements Runnable, ICraftingJob for (String s : opsAndMultiplier.keySet()) { twoIntegers ti = opsAndMultiplier.get( s ); - AELog.info( s + " * " + ti.times + " = " + (ti.perOp * ti.times) ); + AELog.crafting( s + " * " + ti.times + " = " + (ti.perOp * ti.times) ); } - AELog.info( "------------- " + getByteTotal() + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" ); + AELog.crafting( "------------- " + getByteTotal() + "b simulate" + timer.elapsed( TimeUnit.MILLISECONDS ) + "ms" ); } catch (CraftBranchFailure e1) { @@ -197,7 +197,7 @@ public class CraftingJob implements Runnable, ICraftingJob } catch (InterruptedException e1) { - AELog.info( "Crafting calculation canceled." ); + AELog.crafting( "Crafting calculation canceled." ); finish(); return; } @@ -208,7 +208,7 @@ public class CraftingJob implements Runnable, ICraftingJob } catch (InterruptedException e1) { - AELog.info( "Crafting calculation canceled." ); + AELog.crafting( "Crafting calculation canceled." ); finish(); return; } @@ -336,7 +336,7 @@ public class CraftingJob implements Runnable, ICraftingJob private void log(String string) { - // AELog.info( string ); + // AELog.crafting( string ); } public void addBytes(long crafts) diff --git a/crafting/MECraftingInventory.java b/crafting/MECraftingInventory.java index eeef951b..c44c465a 100644 --- a/crafting/MECraftingInventory.java +++ b/crafting/MECraftingInventory.java @@ -94,8 +94,6 @@ public class MECraftingInventory implements IMEInventory if ( input == null ) return null; - // AELog.info( mode.toString() + "Inject: " + input.toString() ); - if ( mode == Actionable.MODULATE ) { if ( logInjections ) @@ -112,8 +110,6 @@ public class MECraftingInventory implements IMEInventory if ( request == null ) return null; - // AELog.info( mode.toString() + "Extract: " + request.toString() ); - IAEItemStack list = localCache.findPrecise( request ); if ( list == null || list.getStackSize() == 0 ) return null;