From bdc438fc6251a1834d6bc8b2c718cd77d3f59a3a Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 8 May 2017 19:28:50 +0100 Subject: [PATCH 1/5] Add a basic logging system This adds a common ILogger interface and two built-in loggers - one which prints to stdout, the other using a Log4J logger. These are split up as not to cause dependency issues for emulators. The stdout logger is enabled by default, but the ComputerCraft mod class will swap over to using FML's mod specific logger, which provides a more consistent look with the rest of Minecraft. --- .../dan200/computercraft/ComputerCraft.java | 4 ++ .../computercraft/core/logger/ILogger.java | 10 +++ .../core/logger/Log4JLogger.java | 59 +++++++++++++++++ .../computercraft/core/logger/Logger.java | 65 +++++++++++++++++++ .../core/logger/StdoutLogger.java | 20 ++++++ 5 files changed, 158 insertions(+) create mode 100644 src/main/java/dan200/computercraft/core/logger/ILogger.java create mode 100644 src/main/java/dan200/computercraft/core/logger/Log4JLogger.java create mode 100644 src/main/java/dan200/computercraft/core/logger/Logger.java create mode 100644 src/main/java/dan200/computercraft/core/logger/StdoutLogger.java diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 210af293e..219fd00a2 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -20,6 +20,8 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.core.filesystem.ComboMount; import dan200.computercraft.core.filesystem.FileMount; import dan200.computercraft.core.filesystem.JarMount; +import dan200.computercraft.core.logger.Log4JLogger; +import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; import dan200.computercraft.shared.computer.blocks.BlockCommandComputer; import dan200.computercraft.shared.computer.blocks.BlockComputer; @@ -231,6 +233,8 @@ public class ComputerCraft @Mod.EventHandler public void preInit( FMLPreInitializationEvent event ) { + Logger.setInstance( new Log4JLogger( event.getModLog() ) ); + // Load config Config.config = new Configuration( event.getSuggestedConfigurationFile() ); Config.config.load(); diff --git a/src/main/java/dan200/computercraft/core/logger/ILogger.java b/src/main/java/dan200/computercraft/core/logger/ILogger.java new file mode 100644 index 000000000..4c23ffc19 --- /dev/null +++ b/src/main/java/dan200/computercraft/core/logger/ILogger.java @@ -0,0 +1,10 @@ +package dan200.computercraft.core.logger; + +import java.util.logging.Level; + +public interface ILogger +{ + void log( Level level, String message ); + + void log( Level level, String message, Throwable t ); +} diff --git a/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java b/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java new file mode 100644 index 000000000..a15b3222d --- /dev/null +++ b/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java @@ -0,0 +1,59 @@ +package dan200.computercraft.core.logger; + +import org.apache.logging.log4j.Logger; + +import java.util.logging.Level; + +public class Log4JLogger implements ILogger +{ + private final org.apache.logging.log4j.Logger logger; + + public Log4JLogger( Logger logger ) + { + this.logger = logger; + } + + @Override + public void log( Level level, String message ) + { + logger.log( mapLevel( level ), message ); + } + + @Override + public void log( Level level, String message, Throwable t ) + { + logger.log( mapLevel( level ), message, t ); + } + + private static org.apache.logging.log4j.Level mapLevel( Level level ) + { + if( level == Level.SEVERE ) + { + return org.apache.logging.log4j.Level.ERROR; + } + else if( level == Level.WARNING ) + { + return org.apache.logging.log4j.Level.WARN; + } + else if( level == Level.INFO ) + { + return org.apache.logging.log4j.Level.INFO; + } + else if( level == Level.FINE ) + { + return org.apache.logging.log4j.Level.DEBUG; + } + else if( level == Level.FINER ) + { + return org.apache.logging.log4j.Level.TRACE; + } + else if( level == Level.ALL ) + { + return org.apache.logging.log4j.Level.ALL; + } + else + { + return org.apache.logging.log4j.Level.INFO; + } + } +} diff --git a/src/main/java/dan200/computercraft/core/logger/Logger.java b/src/main/java/dan200/computercraft/core/logger/Logger.java new file mode 100644 index 000000000..9687e41c5 --- /dev/null +++ b/src/main/java/dan200/computercraft/core/logger/Logger.java @@ -0,0 +1,65 @@ +package dan200.computercraft.core.logger; + +import javax.annotation.Nonnull; +import java.util.logging.Level; + +public class Logger +{ + private static ILogger instance; + + @Nonnull + public static ILogger getInstance() + { + ILogger logger = instance; + if( logger == null ) logger = instance = new StdoutLogger(); + return logger; + } + + public static void setInstance( @Nonnull ILogger logger ) + { + if( logger == null ) throw new NullPointerException( "Logger cannot be null" ); + instance = logger; + } + + public static void log( Level level, String message ) + { + getInstance().log( level, message ); + } + + public static void log( Level level, String message, Throwable t ) + { + getInstance().log( level, message, t ); + } + + public static void error( String message ) + { + getInstance().log( Level.SEVERE, message ); + } + + public static void error( String message, Throwable t ) + { + getInstance().log( Level.SEVERE, message, t ); + } + + public static void warn( String message ) + { + getInstance().log( Level.WARNING, message ); + } + + public static void warn( String message, Throwable t ) + { + getInstance().log( Level.WARNING, message, t ); + } + + /** + * Logs {@code message} and creates a new {@link RuntimeException} using the same message. + * + * @param message The message to log. + * @return The exception using the same message. + */ + public static RuntimeException loggedError( String message ) + { + getInstance().log( Level.SEVERE, message ); + return new RuntimeException( message ); + } +} diff --git a/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java b/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java new file mode 100644 index 000000000..2abea7cd1 --- /dev/null +++ b/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java @@ -0,0 +1,20 @@ +package dan200.computercraft.core.logger; + +import java.util.logging.Level; + +public class StdoutLogger implements ILogger +{ + + @Override + public void log( Level level, String message ) + { + System.out.printf( "[%s] %s\n", level.getName(), message ); + } + + @Override + public void log( Level level, String message, Throwable t ) + { + System.out.printf( "[%s] %s\n", level.getName(), message ); + t.printStackTrace( System.out ); + } +} From 44ba4069c18d2db004b911c9ed2e8e056d1d4547 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 8 May 2017 19:55:51 +0100 Subject: [PATCH 2/5] Print stack traces/add logging messages in several places This will hopefully make it easier to track down various issues which might otherwise go unnoticed or provide little information. The main areas modified are those that external APIs may provide values for or interact with: various providers and ILuaObject/IPeripheral implementations. However, we do also log in a couple of other places which indicate a problem with this, or another, mod. --- src/main/java/dan200/computercraft/ComputerCraft.java | 5 +++-- .../dan200/computercraft/core/computer/Computer.java | 3 ++- .../computercraft/core/computer/ComputerThread.java | 7 ++++--- .../dan200/computercraft/core/lua/LuaJLuaMachine.java | 7 ++++++- .../computercraft/shared/computer/apis/CommandAPI.java | 3 +++ .../computercraft/shared/network/PacketHandler.java | 5 +++-- .../shared/proxy/CCTurtleProxyCommon.java | 10 ++++++---- .../dan200/computercraft/shared/util/IDAssigner.java | 10 ++++++---- 8 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 219fd00a2..f07c8a7ac 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -609,7 +609,7 @@ public class ComputerCraft } catch( Exception e ) { - // mod misbehaved, ignore it + Logger.error( "Peripheral provider " + peripheralProvider + " errored.", e ); } } return null; @@ -653,7 +653,7 @@ public class ComputerCraft } catch( Exception e ) { - // mod misbehaved, ignore it + Logger.error( "Bundled redstone provider " + bundledRedstoneProvider + " errored.", e ); } } return combinedSignal; @@ -677,6 +677,7 @@ public class ComputerCraft catch( Exception e ) { // mod misbehaved, ignore it + Logger.error( "Media provider " + mediaProvider + " errored.", e ); } } return null; diff --git a/src/main/java/dan200/computercraft/core/computer/Computer.java b/src/main/java/dan200/computercraft/core/computer/Computer.java index 712979521..905dea4bf 100644 --- a/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -14,6 +14,7 @@ import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.core.apis.*; import dan200.computercraft.core.filesystem.FileSystem; import dan200.computercraft.core.filesystem.FileSystemException; +import dan200.computercraft.core.logger.Logger; import dan200.computercraft.core.lua.ILuaMachine; import dan200.computercraft.core.lua.LuaJLuaMachine; import dan200.computercraft.core.terminal.Terminal; @@ -469,7 +470,7 @@ public class Computer } catch( FileSystemException e ) { - e.printStackTrace(); + Logger.error( "Cannot mount rom", e ); return false; } } diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index 1915c5afb..5178830e4 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -6,6 +6,8 @@ package dan200.computercraft.core.computer; +import dan200.computercraft.core.logger.Logger; + import java.util.ArrayList; import java.util.Iterator; import java.util.WeakHashMap; @@ -106,8 +108,7 @@ public class ComputerThread try { task.execute(); } catch( Throwable e ) { - System.out.println( "ComputerCraft: Error running task." ); - e.printStackTrace(); + Logger.error( "Error running task", e ); } } } ); @@ -139,7 +140,7 @@ public class ComputerThread // Step 3: abandon if( worker.isAlive() ) { - //System.out.println( "computercraft: Warning! Failed to abort Computer " + computercraft.getDescription() + ". Dangling lua thread could cause errors." ); + Logger.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." ); worker.interrupt(); } } diff --git a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java index 933ca3291..614147aee 100644 --- a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java @@ -15,6 +15,7 @@ import dan200.computercraft.core.apis.ILuaAPI; import dan200.computercraft.core.computer.Computer; import dan200.computercraft.core.computer.ITask; import dan200.computercraft.core.computer.MainThread; +import dan200.computercraft.core.logger.Logger; import org.luaj.vm2.*; import org.luaj.vm2.lib.OneArgFunction; import org.luaj.vm2.lib.VarArgFunction; @@ -183,6 +184,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( LuaError e ) { + Logger.warn( "Could not load bios.lua ", e ); if( m_mainRoutine != null ) { ((LuaThread)m_mainRoutine).abandon(); @@ -327,7 +329,8 @@ public class LuaJLuaMachine implements ILuaMachine { final int method = i; final ILuaObject apiObject = object; - table.set( methods[i], new VarArgFunction() { + final String methodName = methods[i]; + table.set( methodName, new VarArgFunction() { @Override public Varargs invoke( Varargs _args ) { @@ -412,6 +415,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { + Logger.error( "Error running task", t); m_computer.queueEvent( "task_complete", new Object[] { taskID, false, "Java Exception Thrown: " + t.toString() } ); @@ -478,6 +482,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { + Logger.error( "Error calling " + methodName + " on " + apiObject, t ); throw new LuaError( "Java Exception Thrown: " + t.toString(), 0 ); } return LuaValue.varargsOf( toValues( results, 0 ) ); diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index ce7f23e48..edc143b3e 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -11,6 +11,7 @@ import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaTask; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.core.apis.ILuaAPI; +import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.computer.blocks.TileCommandComputer; import dan200.computercraft.shared.util.WorldUtil; import net.minecraft.block.Block; @@ -98,6 +99,7 @@ public class CommandAPI implements ILuaAPI } catch( Throwable t ) { + Logger.error( "Error running command.", t ); return new Object[]{ false, createOutput( "Java Exception Thrown: " + t.toString() ) }; } } @@ -208,6 +210,7 @@ public class CommandAPI implements ILuaAPI catch( Throwable t ) { // Ignore buggy command + Logger.error( "Error running command.", t ); } } } diff --git a/src/main/java/dan200/computercraft/shared/network/PacketHandler.java b/src/main/java/dan200/computercraft/shared/network/PacketHandler.java index 9db6d7717..8b87cc6a1 100644 --- a/src/main/java/dan200/computercraft/shared/network/PacketHandler.java +++ b/src/main/java/dan200/computercraft/shared/network/PacketHandler.java @@ -7,6 +7,7 @@ package dan200.computercraft.shared.network; import dan200.computercraft.ComputerCraft; +import dan200.computercraft.core.logger.Logger; import net.minecraft.network.NetHandlerPlayServer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; @@ -24,7 +25,7 @@ public class PacketHandler } catch( Exception e ) { - e.printStackTrace(); + Logger.error( "Error handling packet", e ); } } @@ -39,7 +40,7 @@ public class PacketHandler } catch( Exception e ) { - e.printStackTrace(); + Logger.error( "Error handling packet", e ); } } } diff --git a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java index 784633e16..eea3264a5 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java @@ -8,6 +8,7 @@ package dan200.computercraft.shared.proxy; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.turtle.ITurtleUpgrade; +import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.items.ComputerItemFactory; import dan200.computercraft.shared.turtle.blocks.BlockTurtle; @@ -83,7 +84,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy int id = upgrade.getLegacyUpgradeID(); if( id >= 0 && id < 64 ) { - throw new RuntimeException( "Error registering '"+upgrade.getUnlocalisedAdjective()+" Turtle'. Legacy UpgradeID '"+id+"' is reserved by ComputerCraft" ); + throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. Legacy UpgradeID '" + id + "' is reserved by ComputerCraft" ); } // Register @@ -117,6 +118,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy } catch( Exception e ) { + Logger.error("Error checking stackability of items", e); } } return null; @@ -253,13 +255,13 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy { if( legacyID >= Short.MAX_VALUE ) { - throw new RuntimeException( "Error registering '"+upgrade.getUnlocalisedAdjective()+" Turtle'. UpgradeID '"+legacyID+"' is out of range" ); + throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is out of range" ); } ITurtleUpgrade existing = m_legacyTurtleUpgrades.get( legacyID ); if( existing != null ) { - throw new RuntimeException( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); + throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); } } @@ -267,7 +269,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy ITurtleUpgrade existing = m_turtleUpgrades.get( id ); if( existing != null ) { - throw new RuntimeException( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); + throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); } // Register diff --git a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java index b1eb6910e..ee7c2dca6 100644 --- a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java +++ b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java @@ -1,5 +1,7 @@ package dan200.computercraft.shared.util; +import dan200.computercraft.core.logger.Logger; + import java.io.*; public class IDAssigner @@ -50,6 +52,7 @@ public class IDAssigner } catch( NumberFormatException e ) { + Logger.error( "Unexpected file '" + content + "' in '" + location.getAbsolutePath() + "'", e ); } } } @@ -82,7 +85,7 @@ public class IDAssigner } catch( IOException e ) { - e.printStackTrace(); + Logger.error( "Cannot open ID file '" + lastidFile + "'", e ); return 0; } @@ -92,7 +95,7 @@ public class IDAssigner } catch( NumberFormatException e ) { - e.printStackTrace(); + Logger.error( "Cannot parse ID file '" + lastidFile + "', perhaps it is corrupt?", e ); return 0; } } @@ -107,8 +110,7 @@ public class IDAssigner } catch( IOException e ) { - System.out.println( "An error occured while trying to create the computer folder. Please check you have relevant permissions." ); - e.printStackTrace(); + Logger.error( "An error occured while trying to create the computer folder. Please check you have relevant permissions.", e ); } return id; From a0b6cbb671af768ddd071f235d30989b142c68bd Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 13 May 2017 22:26:35 +0100 Subject: [PATCH 3/5] Remove ILogger facade Just use global Log4j logger on the ComputerCraft class. --- .../dan200/computercraft/ComputerCraft.java | 14 ++-- .../computercraft/core/computer/Computer.java | 3 +- .../core/computer/ComputerThread.java | 6 +- .../computercraft/core/logger/ILogger.java | 10 --- .../core/logger/Log4JLogger.java | 59 ----------------- .../computercraft/core/logger/Logger.java | 65 ------------------- .../core/logger/StdoutLogger.java | 20 ------ .../core/lua/LuaJLuaMachine.java | 8 +-- .../shared/computer/apis/CommandAPI.java | 6 +- .../shared/network/PacketHandler.java | 5 +- .../shared/proxy/CCTurtleProxyCommon.java | 19 ++++-- .../computercraft/shared/util/IDAssigner.java | 10 +-- 12 files changed, 39 insertions(+), 186 deletions(-) delete mode 100644 src/main/java/dan200/computercraft/core/logger/ILogger.java delete mode 100644 src/main/java/dan200/computercraft/core/logger/Log4JLogger.java delete mode 100644 src/main/java/dan200/computercraft/core/logger/Logger.java delete mode 100644 src/main/java/dan200/computercraft/core/logger/StdoutLogger.java diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index f07c8a7ac..448b08c26 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -20,8 +20,6 @@ import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.core.filesystem.ComboMount; import dan200.computercraft.core.filesystem.FileMount; import dan200.computercraft.core.filesystem.JarMount; -import dan200.computercraft.core.logger.Log4JLogger; -import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.common.DefaultBundledRedstoneProvider; import dan200.computercraft.shared.computer.blocks.BlockCommandComputer; import dan200.computercraft.shared.computer.blocks.BlockComputer; @@ -70,6 +68,7 @@ import net.minecraftforge.fml.common.network.FMLEventChannel; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; import net.minecraftforge.fml.relauncher.Side; +import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -209,6 +208,9 @@ public class ComputerCraft // Creative public static CreativeTabMain mainCreativeTab; + // Logging + public static Logger log; + // API users private static List peripheralProviders = new ArrayList(); private static List bundledRedstoneProviders = new ArrayList(); @@ -233,7 +235,7 @@ public class ComputerCraft @Mod.EventHandler public void preInit( FMLPreInitializationEvent event ) { - Logger.setInstance( new Log4JLogger( event.getModLog() ) ); + log = event.getModLog(); // Load config Config.config = new Configuration( event.getSuggestedConfigurationFile() ); @@ -609,7 +611,7 @@ public class ComputerCraft } catch( Exception e ) { - Logger.error( "Peripheral provider " + peripheralProvider + " errored.", e ); + ComputerCraft.log.error( "Peripheral provider " + peripheralProvider + " errored.", e ); } } return null; @@ -653,7 +655,7 @@ public class ComputerCraft } catch( Exception e ) { - Logger.error( "Bundled redstone provider " + bundledRedstoneProvider + " errored.", e ); + ComputerCraft.log.error( "Bundled redstone provider " + bundledRedstoneProvider + " errored.", e ); } } return combinedSignal; @@ -677,7 +679,7 @@ public class ComputerCraft catch( Exception e ) { // mod misbehaved, ignore it - Logger.error( "Media provider " + mediaProvider + " errored.", e ); + ComputerCraft.log.error( "Media provider " + mediaProvider + " errored.", e ); } } return null; diff --git a/src/main/java/dan200/computercraft/core/computer/Computer.java b/src/main/java/dan200/computercraft/core/computer/Computer.java index 905dea4bf..885f85188 100644 --- a/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -14,7 +14,6 @@ import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.core.apis.*; import dan200.computercraft.core.filesystem.FileSystem; import dan200.computercraft.core.filesystem.FileSystemException; -import dan200.computercraft.core.logger.Logger; import dan200.computercraft.core.lua.ILuaMachine; import dan200.computercraft.core.lua.LuaJLuaMachine; import dan200.computercraft.core.terminal.Terminal; @@ -470,7 +469,7 @@ public class Computer } catch( FileSystemException e ) { - Logger.error( "Cannot mount rom", e ); + ComputerCraft.log.error( "Cannot mount rom", e ); return false; } } diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index 5178830e4..4eda28037 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -6,7 +6,7 @@ package dan200.computercraft.core.computer; -import dan200.computercraft.core.logger.Logger; +import dan200.computercraft.ComputerCraft; import java.util.ArrayList; import java.util.Iterator; @@ -108,7 +108,7 @@ public class ComputerThread try { task.execute(); } catch( Throwable e ) { - Logger.error( "Error running task", e ); + ComputerCraft.log.error( "Error running task", e ); } } } ); @@ -140,7 +140,7 @@ public class ComputerThread // Step 3: abandon if( worker.isAlive() ) { - Logger.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." ); + ComputerCraft.log.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." ); worker.interrupt(); } } diff --git a/src/main/java/dan200/computercraft/core/logger/ILogger.java b/src/main/java/dan200/computercraft/core/logger/ILogger.java deleted file mode 100644 index 4c23ffc19..000000000 --- a/src/main/java/dan200/computercraft/core/logger/ILogger.java +++ /dev/null @@ -1,10 +0,0 @@ -package dan200.computercraft.core.logger; - -import java.util.logging.Level; - -public interface ILogger -{ - void log( Level level, String message ); - - void log( Level level, String message, Throwable t ); -} diff --git a/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java b/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java deleted file mode 100644 index a15b3222d..000000000 --- a/src/main/java/dan200/computercraft/core/logger/Log4JLogger.java +++ /dev/null @@ -1,59 +0,0 @@ -package dan200.computercraft.core.logger; - -import org.apache.logging.log4j.Logger; - -import java.util.logging.Level; - -public class Log4JLogger implements ILogger -{ - private final org.apache.logging.log4j.Logger logger; - - public Log4JLogger( Logger logger ) - { - this.logger = logger; - } - - @Override - public void log( Level level, String message ) - { - logger.log( mapLevel( level ), message ); - } - - @Override - public void log( Level level, String message, Throwable t ) - { - logger.log( mapLevel( level ), message, t ); - } - - private static org.apache.logging.log4j.Level mapLevel( Level level ) - { - if( level == Level.SEVERE ) - { - return org.apache.logging.log4j.Level.ERROR; - } - else if( level == Level.WARNING ) - { - return org.apache.logging.log4j.Level.WARN; - } - else if( level == Level.INFO ) - { - return org.apache.logging.log4j.Level.INFO; - } - else if( level == Level.FINE ) - { - return org.apache.logging.log4j.Level.DEBUG; - } - else if( level == Level.FINER ) - { - return org.apache.logging.log4j.Level.TRACE; - } - else if( level == Level.ALL ) - { - return org.apache.logging.log4j.Level.ALL; - } - else - { - return org.apache.logging.log4j.Level.INFO; - } - } -} diff --git a/src/main/java/dan200/computercraft/core/logger/Logger.java b/src/main/java/dan200/computercraft/core/logger/Logger.java deleted file mode 100644 index 9687e41c5..000000000 --- a/src/main/java/dan200/computercraft/core/logger/Logger.java +++ /dev/null @@ -1,65 +0,0 @@ -package dan200.computercraft.core.logger; - -import javax.annotation.Nonnull; -import java.util.logging.Level; - -public class Logger -{ - private static ILogger instance; - - @Nonnull - public static ILogger getInstance() - { - ILogger logger = instance; - if( logger == null ) logger = instance = new StdoutLogger(); - return logger; - } - - public static void setInstance( @Nonnull ILogger logger ) - { - if( logger == null ) throw new NullPointerException( "Logger cannot be null" ); - instance = logger; - } - - public static void log( Level level, String message ) - { - getInstance().log( level, message ); - } - - public static void log( Level level, String message, Throwable t ) - { - getInstance().log( level, message, t ); - } - - public static void error( String message ) - { - getInstance().log( Level.SEVERE, message ); - } - - public static void error( String message, Throwable t ) - { - getInstance().log( Level.SEVERE, message, t ); - } - - public static void warn( String message ) - { - getInstance().log( Level.WARNING, message ); - } - - public static void warn( String message, Throwable t ) - { - getInstance().log( Level.WARNING, message, t ); - } - - /** - * Logs {@code message} and creates a new {@link RuntimeException} using the same message. - * - * @param message The message to log. - * @return The exception using the same message. - */ - public static RuntimeException loggedError( String message ) - { - getInstance().log( Level.SEVERE, message ); - return new RuntimeException( message ); - } -} diff --git a/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java b/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java deleted file mode 100644 index 2abea7cd1..000000000 --- a/src/main/java/dan200/computercraft/core/logger/StdoutLogger.java +++ /dev/null @@ -1,20 +0,0 @@ -package dan200.computercraft.core.logger; - -import java.util.logging.Level; - -public class StdoutLogger implements ILogger -{ - - @Override - public void log( Level level, String message ) - { - System.out.printf( "[%s] %s\n", level.getName(), message ); - } - - @Override - public void log( Level level, String message, Throwable t ) - { - System.out.printf( "[%s] %s\n", level.getName(), message ); - t.printStackTrace( System.out ); - } -} diff --git a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java index 614147aee..8da8bab3c 100644 --- a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java @@ -15,7 +15,7 @@ import dan200.computercraft.core.apis.ILuaAPI; import dan200.computercraft.core.computer.Computer; import dan200.computercraft.core.computer.ITask; import dan200.computercraft.core.computer.MainThread; -import dan200.computercraft.core.logger.Logger; + import org.luaj.vm2.*; import org.luaj.vm2.lib.OneArgFunction; import org.luaj.vm2.lib.VarArgFunction; @@ -184,7 +184,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( LuaError e ) { - Logger.warn( "Could not load bios.lua ", e ); + ComputerCraft.log.warn( "Could not load bios.lua ", e ); if( m_mainRoutine != null ) { ((LuaThread)m_mainRoutine).abandon(); @@ -415,7 +415,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { - Logger.error( "Error running task", t); + ComputerCraft.log.error( "Error running task", t); m_computer.queueEvent( "task_complete", new Object[] { taskID, false, "Java Exception Thrown: " + t.toString() } ); @@ -482,7 +482,7 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { - Logger.error( "Error calling " + methodName + " on " + apiObject, t ); + ComputerCraft.log.error( "Error calling " + methodName + " on " + apiObject, t ); throw new LuaError( "Java Exception Thrown: " + t.toString(), 0 ); } return LuaValue.varargsOf( toValues( results, 0 ) ); diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index edc143b3e..26f307f60 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -7,11 +7,11 @@ package dan200.computercraft.shared.computer.apis; import com.google.common.collect.ImmutableMap; +import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.ILuaTask; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.core.apis.ILuaAPI; -import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.computer.blocks.TileCommandComputer; import dan200.computercraft.shared.util.WorldUtil; import net.minecraft.block.Block; @@ -99,7 +99,7 @@ public class CommandAPI implements ILuaAPI } catch( Throwable t ) { - Logger.error( "Error running command.", t ); + ComputerCraft.log.error( "Error running command.", t ); return new Object[]{ false, createOutput( "Java Exception Thrown: " + t.toString() ) }; } } @@ -210,7 +210,7 @@ public class CommandAPI implements ILuaAPI catch( Throwable t ) { // Ignore buggy command - Logger.error( "Error running command.", t ); + ComputerCraft.log.error( "Error running command.", t ); } } } diff --git a/src/main/java/dan200/computercraft/shared/network/PacketHandler.java b/src/main/java/dan200/computercraft/shared/network/PacketHandler.java index 8b87cc6a1..64c669794 100644 --- a/src/main/java/dan200/computercraft/shared/network/PacketHandler.java +++ b/src/main/java/dan200/computercraft/shared/network/PacketHandler.java @@ -7,7 +7,6 @@ package dan200.computercraft.shared.network; import dan200.computercraft.ComputerCraft; -import dan200.computercraft.core.logger.Logger; import net.minecraft.network.NetHandlerPlayServer; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; @@ -25,7 +24,7 @@ public class PacketHandler } catch( Exception e ) { - Logger.error( "Error handling packet", e ); + ComputerCraft.log.error( "Error handling packet", e ); } } @@ -40,7 +39,7 @@ public class PacketHandler } catch( Exception e ) { - Logger.error( "Error handling packet", e ); + ComputerCraft.log.error( "Error handling packet", e ); } } } diff --git a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java index eea3264a5..b5d12a48b 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java @@ -8,7 +8,6 @@ package dan200.computercraft.shared.proxy; import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.turtle.ITurtleUpgrade; -import dan200.computercraft.core.logger.Logger; import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.items.ComputerItemFactory; import dan200.computercraft.shared.turtle.blocks.BlockTurtle; @@ -84,7 +83,9 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy int id = upgrade.getLegacyUpgradeID(); if( id >= 0 && id < 64 ) { - throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. Legacy UpgradeID '" + id + "' is reserved by ComputerCraft" ); + String message = "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. Legacy UpgradeID '" + id + "' is reserved by ComputerCraft"; + ComputerCraft.log.error( message ); + throw new RuntimeException( message ); } // Register @@ -118,7 +119,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy } catch( Exception e ) { - Logger.error("Error checking stackability of items", e); + ComputerCraft.log.error("Error checking stackability of items", e); } } return null; @@ -255,13 +256,17 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy { if( legacyID >= Short.MAX_VALUE ) { - throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is out of range" ); + String message = "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is out of range"; + ComputerCraft.log.error( message ); + throw new RuntimeException( message ); } ITurtleUpgrade existing = m_legacyTurtleUpgrades.get( legacyID ); if( existing != null ) { - throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); + String message = "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + legacyID + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'"; + ComputerCraft.log.error( message ); + throw new RuntimeException( message ); } } @@ -269,7 +274,9 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy ITurtleUpgrade existing = m_turtleUpgrades.get( id ); if( existing != null ) { - throw Logger.loggedError( "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'" ); + String message = "Error registering '" + upgrade.getUnlocalisedAdjective() + " Turtle'. UpgradeID '" + id + "' is already registered by '" + existing.getUnlocalisedAdjective() + " Turtle'"; + ComputerCraft.log.error( message ); + throw new RuntimeException( message ); } // Register diff --git a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java index ee7c2dca6..489e1c075 100644 --- a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java +++ b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java @@ -1,6 +1,6 @@ package dan200.computercraft.shared.util; -import dan200.computercraft.core.logger.Logger; +import dan200.computercraft.ComputerCraft; import java.io.*; @@ -52,7 +52,7 @@ public class IDAssigner } catch( NumberFormatException e ) { - Logger.error( "Unexpected file '" + content + "' in '" + location.getAbsolutePath() + "'", e ); + ComputerCraft.log.error( "Unexpected file '" + content + "' in '" + location.getAbsolutePath() + "'", e ); } } } @@ -85,7 +85,7 @@ public class IDAssigner } catch( IOException e ) { - Logger.error( "Cannot open ID file '" + lastidFile + "'", e ); + ComputerCraft.log.error( "Cannot open ID file '" + lastidFile + "'", e ); return 0; } @@ -95,7 +95,7 @@ public class IDAssigner } catch( NumberFormatException e ) { - Logger.error( "Cannot parse ID file '" + lastidFile + "', perhaps it is corrupt?", e ); + ComputerCraft.log.error( "Cannot parse ID file '" + lastidFile + "', perhaps it is corrupt?", e ); return 0; } } @@ -110,7 +110,7 @@ public class IDAssigner } catch( IOException e ) { - Logger.error( "An error occured while trying to create the computer folder. Please check you have relevant permissions.", e ); + ComputerCraft.log.error( "An error occured while trying to create the computer folder. Please check you have relevant permissions.", e ); } return id; From efb0065ebd3a37df5c32bca9c5fbdea8783e773e Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 May 2017 15:59:09 +0100 Subject: [PATCH 4/5] Add config option to disable certain error messages --- src/main/java/dan200/computercraft/ComputerCraft.java | 6 ++++++ .../computercraft/core/computer/ComputerThread.java | 2 +- .../dan200/computercraft/core/lua/LuaJLuaMachine.java | 10 ++++++++-- .../computercraft/shared/computer/apis/CommandAPI.java | 10 ++++++++-- .../shared/proxy/CCTurtleProxyCommon.java | 2 +- .../resources/assets/computercraft/lang/en_US.lang | 1 + 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 448b08c26..1ed5e4e7e 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -107,6 +107,7 @@ public class ComputerCraft public static String http_whitelist = "*"; public static boolean disable_lua51_features = false; public static String default_computer_settings = ""; + public static boolean logPeripheralErrors = true; public static boolean enableCommandBlock = false; public static boolean turtlesNeedFuel = true; @@ -180,6 +181,7 @@ public class ComputerCraft public static Property http_whitelist; public static Property disable_lua51_features; public static Property default_computer_settings; + public static Property logPeripheralErrors; public static Property enableCommandBlock; public static Property turtlesNeedFuel; @@ -253,6 +255,10 @@ public class ComputerCraft Config.default_computer_settings = Config.config.get( Configuration.CATEGORY_GENERAL, "default_computer_settings", default_computer_settings ); Config.default_computer_settings.setComment( "A comma seperated list of default system settings to set on new computers. Example: \"shell.autocomplete=false,lua.autocomplete=false,edit.autocomplete=false\" will disable all autocompletion" ); + Config.logPeripheralErrors = Config.config.get( Configuration.CATEGORY_GENERAL, "logPeripheralErrors", logPeripheralErrors ); + Config.logPeripheralErrors.setComment( "Log exceptions thrown by peripherals and other Lua objects.\n" + + "This makes it easier for mod authors to debug problems, but may result in log spam should people use buggy methods." ); + Config.enableCommandBlock = Config.config.get( Configuration.CATEGORY_GENERAL, "enableCommandBlock", enableCommandBlock ); Config.enableCommandBlock.setComment( "Enable Command Block peripheral support" ); diff --git a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java index 4eda28037..f84a2e5c8 100644 --- a/src/main/java/dan200/computercraft/core/computer/ComputerThread.java +++ b/src/main/java/dan200/computercraft/core/computer/ComputerThread.java @@ -140,7 +140,7 @@ public class ComputerThread // Step 3: abandon if( worker.isAlive() ) { - ComputerCraft.log.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." ); + // ComputerCraft.log.warn( "Failed to abort Computer " + computer.getID() + ". Dangling lua thread could cause errors." ); worker.interrupt(); } } diff --git a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java index 8da8bab3c..574aed974 100644 --- a/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/LuaJLuaMachine.java @@ -415,7 +415,10 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { - ComputerCraft.log.error( "Error running task", t); + if( ComputerCraft.logPeripheralErrors ) + { + ComputerCraft.log.error( "Error running task", t ); + } m_computer.queueEvent( "task_complete", new Object[] { taskID, false, "Java Exception Thrown: " + t.toString() } ); @@ -482,7 +485,10 @@ public class LuaJLuaMachine implements ILuaMachine } catch( Throwable t ) { - ComputerCraft.log.error( "Error calling " + methodName + " on " + apiObject, t ); + if( ComputerCraft.logPeripheralErrors ) + { + ComputerCraft.log.error( "Error calling " + methodName + " on " + apiObject, t ); + } throw new LuaError( "Java Exception Thrown: " + t.toString(), 0 ); } return LuaValue.varargsOf( toValues( results, 0 ) ); diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index 26f307f60..2f6f54cf1 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -99,7 +99,10 @@ public class CommandAPI implements ILuaAPI } catch( Throwable t ) { - ComputerCraft.log.error( "Error running command.", t ); + if( ComputerCraft.logPeripheralErrors ) + { + ComputerCraft.log.error( "Error running command.", t ); + } return new Object[]{ false, createOutput( "Java Exception Thrown: " + t.toString() ) }; } } @@ -210,7 +213,10 @@ public class CommandAPI implements ILuaAPI catch( Throwable t ) { // Ignore buggy command - ComputerCraft.log.error( "Error running command.", t ); + if( ComputerCraft.logPeripheralErrors ) + { + ComputerCraft.log.error( "Error running command.", t ); + } } } } diff --git a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java index b5d12a48b..928cb97fc 100644 --- a/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java +++ b/src/main/java/dan200/computercraft/shared/proxy/CCTurtleProxyCommon.java @@ -119,7 +119,7 @@ public abstract class CCTurtleProxyCommon implements ICCTurtleProxy } catch( Exception e ) { - ComputerCraft.log.error("Error checking stackability of items", e); + ComputerCraft.log.error("Error getting computer upgrade item", e); } } return null; diff --git a/src/main/resources/assets/computercraft/lang/en_US.lang b/src/main/resources/assets/computercraft/lang/en_US.lang index 98361fac9..18ee56160 100644 --- a/src/main/resources/assets/computercraft/lang/en_US.lang +++ b/src/main/resources/assets/computercraft/lang/en_US.lang @@ -44,6 +44,7 @@ gui.computercraft:config.http_enable=Enable HTTP API gui.computercraft:config.http_whitelist=HTTP whitelist gui.computercraft:config.disable_lua51_features=Disable Lua 5.1 features gui.computercraft:config.default_computer_settings=Default Computer settings +gui.computercraft:config.log_peripheral_errors=Log peripheral errors gui.computercraft:config.enable_command_block=Enable command block peripheral gui.computercraft:config.modem_range=Modem range (default) gui.computercraft:config.modem_high_altitude_range=Modem range (high-altitude) From 0e1135ed97c968fbefe1b5b06c6da496d1fb27f6 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 May 2017 19:35:07 +0100 Subject: [PATCH 5/5] Disable peripheral logging by default --- src/main/java/dan200/computercraft/ComputerCraft.java | 2 +- .../dan200/computercraft/shared/computer/apis/CommandAPI.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index 1ed5e4e7e..75280d0b8 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -107,7 +107,7 @@ public class ComputerCraft public static String http_whitelist = "*"; public static boolean disable_lua51_features = false; public static String default_computer_settings = ""; - public static boolean logPeripheralErrors = true; + public static boolean logPeripheralErrors = false; public static boolean enableCommandBlock = false; public static boolean turtlesNeedFuel = true; diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java index 2f6f54cf1..fa708a193 100644 --- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java +++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java @@ -215,7 +215,7 @@ public class CommandAPI implements ILuaAPI // Ignore buggy command if( ComputerCraft.logPeripheralErrors ) { - ComputerCraft.log.error( "Error running command.", t ); + ComputerCraft.log.error( "Error checking permissions of command.", t ); } } }