Explorar el Código

Upgrading some logs

Zoey76 hace 9 años
padre
commit
b4e8ed0000

+ 13 - 13
L2J_Server/java/com/l2jserver/UPnPService.java

@@ -21,12 +21,12 @@ package com.l2jserver;
 import java.io.IOException;
 import java.net.InetAddress;
 import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import org.bitlet.weupnp.GatewayDevice;
 import org.bitlet.weupnp.GatewayDiscover;
 import org.bitlet.weupnp.PortMappingEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.SAXException;
 
 /**
@@ -34,7 +34,7 @@ import org.xml.sax.SAXException;
  */
 public class UPnPService
 {
-	private static final Logger _log = Logger.getLogger(UPnPService.class.getName());
+	private static final Logger _log = LoggerFactory.getLogger(UPnPService.class);
 	private static final String PROTOCOL = "TCP";
 	
 	private final GatewayDiscover _gatewayDiscover = new GatewayDiscover();
@@ -48,7 +48,7 @@ public class UPnPService
 		}
 		catch (Exception e)
 		{
-			_log.log(Level.WARNING, getClass().getSimpleName() + ": error while initializing: ", e);
+			_log.warn("{}: There was a problem while initializing the UPnP Service!", getClass().getSimpleName(), e);
 		}
 	}
 	
@@ -56,16 +56,16 @@ public class UPnPService
 	{
 		if (!Config.ENABLE_UPNP)
 		{
-			_log.log(Level.WARNING, "UPnP Service is disabled.");
+			_log.info("UPnP Service is disabled.");
 			return;
 		}
 		
-		_log.log(Level.INFO, "Looking for UPnP Gateway Devices...");
+		_log.info("Looking for UPnP Gateway Devices...");
 		
 		final Map<InetAddress, GatewayDevice> gateways = _gatewayDiscover.discover();
 		if (gateways.isEmpty())
 		{
-			_log.log(Level.INFO, "No UPnP gateways found");
+			_log.info("No UPnP gateways found.");
 			return;
 		}
 		
@@ -73,15 +73,15 @@ public class UPnPService
 		_activeGW = _gatewayDiscover.getValidGateway();
 		if (_activeGW != null)
 		{
-			_log.log(Level.INFO, "Using UPnP gateway: " + _activeGW.getFriendlyName());
+			_log.info("Using UPnP gateway: {}", _activeGW.getFriendlyName());
 		}
 		else
 		{
-			_log.log(Level.INFO, "No active UPnP gateway found");
+			_log.info("No active UPnP gateway found.");
 			return;
 		}
 		
-		_log.log(Level.INFO, "Using local address: " + _activeGW.getLocalAddress().getHostAddress() + " External address: " + _activeGW.getExternalIPAddress());
+		_log.info("Using local address: {} External address: {}", _activeGW.getLocalAddress().getHostAddress(), _activeGW.getExternalIPAddress());
 		
 		if (Server.serverMode == Server.MODE_GAMESERVER)
 		{
@@ -121,11 +121,11 @@ public class UPnPService
 		
 		if (_activeGW.addPortMapping(port, port, localAddress.getHostAddress(), PROTOCOL, description))
 		{
-			_log.log(Level.INFO, "Mapping successfull on [" + localAddress.getHostAddress() + ":" + port + "]");
+			_log.info("Mapping successfull on ", localAddress.getHostAddress(), port);
 		}
 		else
 		{
-			_log.log(Level.INFO, "Mapping failed on [" + localAddress.getHostAddress() + ":" + port + "] - Already mapped?");
+			_log.info("Mapping failed on [{}:{}] - Already mapped?", localAddress.getHostAddress(), port);
 		}
 	}
 	
@@ -133,7 +133,7 @@ public class UPnPService
 	{
 		if (_activeGW.deletePortMapping(port, PROTOCOL))
 		{
-			_log.log(Level.INFO, "Mapping was deleted from [" + _activeGW.getLocalAddress().getHostAddress() + ":" + port + "]");
+			_log.info("Mapping was deleted from [{}:{}]", _activeGW.getLocalAddress().getHostAddress(), port);
 		}
 	}
 	

+ 5 - 3
L2J_Server/java/com/l2jserver/commons/database/pool/AbstractConnectionFactory.java

@@ -20,7 +20,9 @@ package com.l2jserver.commons.database.pool;
 
 import java.sql.Connection;
 import java.sql.SQLException;
-import java.util.logging.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Abstract Connection Factory.
@@ -29,7 +31,7 @@ import java.util.logging.Logger;
 public abstract class AbstractConnectionFactory implements IConnectionFactory
 {
 	/** The logger. */
-	protected static final Logger LOG = Logger.getLogger(AbstractConnectionFactory.class.getName());
+	protected static final Logger LOG = LoggerFactory.getLogger(AbstractConnectionFactory.class);
 	
 	@Override
 	public Connection getConnection()
@@ -43,7 +45,7 @@ public abstract class AbstractConnectionFactory implements IConnectionFactory
 			}
 			catch (SQLException e)
 			{
-				LOG.warning(getClass().getSimpleName() + ": Unable to get a connection: " + e.getMessage());
+				LOG.warn("{}: Unable to get a connection!", getClass().getSimpleName(), e);
 			}
 		}
 		return con;

+ 1 - 1
L2J_Server/java/com/l2jserver/commons/database/pool/impl/BoneCPConnectionFactory.java

@@ -35,7 +35,7 @@ final class BoneCPConnectionFactory extends AbstractConnectionFactory
 	
 	public BoneCPConnectionFactory()
 	{
-		LOG.severe("BoneCP is not supported yet, nothing is going to work!");
+		LOG.error("BoneCP is not supported yet, nothing is going to work!");
 	}
 	
 	@Override

+ 5 - 10
L2J_Server/java/com/l2jserver/commons/database/pool/impl/C3P0ConnectionFactory.java

@@ -43,7 +43,7 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
 		if (Config.DATABASE_MAX_CONNECTIONS < 2)
 		{
 			Config.DATABASE_MAX_CONNECTIONS = 2;
-			LOG.warning("A minimum of " + Config.DATABASE_MAX_CONNECTIONS + " db connections are required.");
+			LOG.warn("A minimum of {} database connections are required.", Config.DATABASE_MAX_CONNECTIONS);
 		}
 		
 		_dataSource = new ComboPooledDataSource();
@@ -88,8 +88,7 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
 		}
 		catch (PropertyVetoException e)
 		{
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			LOG.error("There has been a problem setting the driver class!", e);
 		}
 		_dataSource.setJdbcUrl(Config.DATABASE_URL);
 		_dataSource.setUser(Config.DATABASE_LOGIN);
@@ -102,14 +101,10 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
 		}
 		catch (SQLException e)
 		{
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			LOG.warn("There has been a problem closing the test connection!", e);
 		}
 		
-		if (Config.DEBUG)
-		{
-			LOG.fine("Database Connection Working");
-		}
+		LOG.debug("Database connection working.");
 	}
 	
 	@Override
@@ -121,7 +116,7 @@ final class C3P0ConnectionFactory extends AbstractConnectionFactory
 		}
 		catch (Exception e)
 		{
-			LOG.info(e.getMessage());
+			LOG.warn("There has been a problem closing the data source!", e);
 		}
 	}
 	

+ 1 - 1
L2J_Server/java/com/l2jserver/commons/database/pool/impl/HikariCPConnectionFactory.java

@@ -54,7 +54,7 @@ final class HikariCPConnectionFactory extends AbstractConnectionFactory
 		}
 		catch (Exception e)
 		{
-			LOG.info(e.getMessage());
+			LOG.warn("There has been a problem closing the data source!", e);
 		}
 	}