Browse Source

AI loggers upgrade

Zoey76 9 years ago
parent
commit
950ee7884a

+ 5 - 3
L2J_Server/java/com/l2jserver/gameserver/ai/AbstractAI.java

@@ -23,7 +23,9 @@ import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_FOLLOW;
 import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
 
 import java.util.concurrent.Future;
-import java.util.logging.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -50,7 +52,7 @@ import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager;
  */
 public abstract class AbstractAI implements Ctrl
 {
-	protected final Logger _log = Logger.getLogger(getClass().getName());
+	protected static final Logger _log = LoggerFactory.getLogger(AbstractAI.class.getName());
 	
 	private NextAction _nextAction;
 	
@@ -123,7 +125,7 @@ public abstract class AbstractAI implements Ctrl
 			}
 			catch (Exception e)
 			{
-				_log.warning(getClass().getSimpleName() + ": Error: " + e.getMessage());
+				_log.warn("{}: There has been a problem running the follow task!", getClass().getSimpleName(), e);
 			}
 		}
 	}

+ 0 - 1
L2J_Server/java/com/l2jserver/gameserver/ai/Ctrl.java

@@ -44,7 +44,6 @@ import com.l2jserver.gameserver.model.actor.L2Character;
  */
 public interface Ctrl
 {
-	
 	/**
 	 * Gets the actor.
 	 * @return the actor

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/ai/L2AttackableAI.java

@@ -840,7 +840,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 			}
 			catch (NullPointerException e)
 			{
-				_log.warning(getClass().getSimpleName() + ": thinkAttack() faction call failed: " + e.getMessage());
+				_log.warn("{}: There has been a problem trying to think the attack!", getClass().getSimpleName(), e);
 			}
 		}
 		
@@ -2064,7 +2064,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		catch (NullPointerException e)
 		{
 			setIntention(AI_INTENTION_ACTIVE);
-			_log.warning(getClass().getSimpleName() + ": " + this + " - failed executing movementDisable(): " + e.getMessage());
+			_log.warn("{}: {} - failed executing movementDisable()!", getClass().getSimpleName(), this, e);
 			return;
 		}
 	}
@@ -2628,7 +2628,7 @@ public class L2AttackableAI extends L2CharacterAI implements Runnable
 		}
 		catch (Exception e)
 		{
-			_log.warning(getClass().getSimpleName() + ": " + this + " -  onEvtThink() failed: " + e.getMessage());
+			_log.warn("{}: {} -  onEvtThink() failed!", getClass().getSimpleName(), this, e);
 		}
 		finally
 		{

+ 3 - 3
L2J_Server/java/com/l2jserver/gameserver/ai/L2CharacterAI.java

@@ -485,7 +485,7 @@ public class L2CharacterAI extends AbstractAI
 		setTarget(object);
 		if ((object.getX() == 0) && (object.getY() == 0)) // TODO: Find the drop&spawn bug
 		{
-			_log.warning("Object in coords 0,0 - using a temporary fix");
+			_log.warn("Object in coords 0,0 - using a temporary fix");
 			object.setXYZ(getActor().getX(), getActor().getY(), getActor().getZ() + 5);
 		}
 		
@@ -991,7 +991,7 @@ public class L2CharacterAI extends AbstractAI
 	{
 		if (worldPosition == null)
 		{
-			_log.warning("maybeMoveToPosition: worldPosition == NULL!");
+			_log.warn("maybeMoveToPosition: worldPosition == NULL!");
 			return false;
 		}
 		
@@ -1063,7 +1063,7 @@ public class L2CharacterAI extends AbstractAI
 		// Get the distance between the current position of the L2Character and the target (x,y)
 		if (target == null)
 		{
-			_log.warning("maybeMoveToPawn: target == NULL!");
+			_log.warn("maybeMoveToPawn: target == NULL!");
 			return false;
 		}
 		if (offset < 0)

+ 3 - 10
L2J_Server/java/com/l2jserver/gameserver/ai/L2FortSiegeGuardAI.java

@@ -25,7 +25,6 @@ import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
 import java.util.Collection;
 import java.util.concurrent.Future;
 
-import com.l2jserver.Config;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -191,10 +190,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	@Override
 	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
 	{
-		if (Config.DEBUG)
-		{
-			_log.warning(getClass().getSimpleName() + ": changeIntention(" + intention + ", " + arg0 + ", " + arg1 + ")");
-		}
+		_log.debug("{}: changeIntention({}, {}, {})", getClass().getSimpleName(), intention, arg0, arg1);
 		
 		if (intention == AI_INTENTION_IDLE /* || intention == AI_INTENTION_ACTIVE */) // active becomes idle if only a summon is present
 		{
@@ -368,10 +364,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 	 */
 	private void thinkAttack()
 	{
-		if (Config.DEBUG)
-		{
-			_log.warning(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
-		}
+		_log.debug("{}: thinkAttack(); timeout={}", getClass().getSimpleName(), (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		
 		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
 		{
@@ -568,7 +561,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
 		}
 		catch (NullPointerException e)
 		{
-			// _log.warning("AttackableAI: Attack target is NULL.");
+			_log.warn("{}: Attack target is NULL.", getClass().getSimpleName());
 			_actor.setTarget(null);
 			setIntention(AI_INTENTION_IDLE, null, null);
 			return;

+ 2 - 9
L2J_Server/java/com/l2jserver/gameserver/ai/L2SiegeGuardAI.java

@@ -25,7 +25,6 @@ import static com.l2jserver.gameserver.ai.CtrlIntention.AI_INTENTION_IDLE;
 import java.util.Collection;
 import java.util.concurrent.Future;
 
-import com.l2jserver.Config;
 import com.l2jserver.gameserver.GameTimeController;
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.ThreadPoolManager;
@@ -180,10 +179,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	@Override
 	synchronized void changeIntention(CtrlIntention intention, Object arg0, Object arg1)
 	{
-		if (Config.DEBUG)
-		{
-			_log.info(getClass().getSimpleName() + ": changeIntention(" + intention + ", " + arg0 + ", " + arg1 + ")");
-		}
+		_log.debug("{}: changeIntention({}, {}, {})", getClass().getSimpleName(), intention, arg0, arg1);
 		
 		if (intention == AI_INTENTION_IDLE /* || intention == AI_INTENTION_ACTIVE */) // active becomes idle if only a summon is present
 		{
@@ -347,10 +343,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
 	 */
 	private void thinkAttack()
 	{
-		if (Config.DEBUG)
-		{
-			_log.info(getClass().getSimpleName() + ": thinkAttack(); timeout=" + (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
-		}
+		_log.debug("{}: thinkAttack(); timeout={}", getClass().getSimpleName(), (_attackTimeout - GameTimeController.getInstance().getGameTicks()));
 		
 		if (_attackTimeout < GameTimeController.getInstance().getGameTicks())
 		{