Add configurable proxy command logging.

This commit adds a config switch that allows users to turn off
 the logging of proxy commands. It is set to off by default to
 prevent unwanted log spam and keep current behaviour.
Log proxy commands

This commit changes the PluginManager to print a message to
console and the log when a proxy command is executed.
This may assist with debugging and miscellaneous
investigations.
This commit is contained in:
xxyy 2015-10-19 00:50:59 +02:00 committed by md_5
parent 013320fd9e
commit ba448b5670
3 changed files with 17 additions and 0 deletions

View File

@ -40,6 +40,11 @@ public interface ProxyConfig
*/ */
boolean isOnlineMode(); boolean isOnlineMode();
/**
* Whether proxy commands are logged to the proxy log
*/
boolean isLogCommands();
/** /**
* Returns the player max. * Returns the player max.
*/ */

View File

@ -159,6 +159,13 @@ public class PluginManager
{ {
if ( tabResults == null ) if ( tabResults == null )
{ {
if ( proxy.getConfig().isLogCommands() )
{
proxy.getLogger().log( Level.INFO, "{0} executed command: /{1}", new Object[]
{
sender.getName(), commandLine
} );
}
command.execute( sender, args ); command.execute( sender, args );
} else if ( commandLine.contains( " " ) && command instanceof TabExecutor ) } else if ( commandLine.contains( " " ) && command instanceof TabExecutor )
{ {

View File

@ -47,6 +47,10 @@ public class Configuration implements ProxyConfig
* Should we check minecraft.net auth. * Should we check minecraft.net auth.
*/ */
private boolean onlineMode = true; private boolean onlineMode = true;
/**
* Whether we log proxy commands to the proxy log
*/
private boolean logCommands;
private int playerLimit = -1; private int playerLimit = -1;
private Collection<String> disabledCommands; private Collection<String> disabledCommands;
private int throttle = 4000; private int throttle = 4000;
@ -75,6 +79,7 @@ public class Configuration implements ProxyConfig
timeout = adapter.getInt( "timeout", timeout ); timeout = adapter.getInt( "timeout", timeout );
uuid = adapter.getString( "stats", uuid ); uuid = adapter.getString( "stats", uuid );
onlineMode = adapter.getBoolean( "online_mode", onlineMode ); onlineMode = adapter.getBoolean( "online_mode", onlineMode );
logCommands = adapter.getBoolean( "log_commands", logCommands );
playerLimit = adapter.getInt( "player_limit", playerLimit ); playerLimit = adapter.getInt( "player_limit", playerLimit );
throttle = adapter.getInt( "connection_throttle", throttle ); throttle = adapter.getInt( "connection_throttle", throttle );
ipForward = adapter.getBoolean( "ip_forward", ipForward ); ipForward = adapter.getBoolean( "ip_forward", ipForward );