Use new logging for all startup messages
This commit is contained in:
@@ -59,6 +59,8 @@ import org.apache.mina.core.service.IoAcceptor;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import server.CashShop.CashItemFactory;
|
||||
import server.MapleSkillbookInformationProvider;
|
||||
import server.ThreadManager;
|
||||
@@ -84,7 +86,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
public class Server {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(Server.class);
|
||||
private static Server instance = null;
|
||||
|
||||
public static Server getInstance() {
|
||||
@@ -385,7 +387,7 @@ public class Server {
|
||||
wldRLock.unlock();
|
||||
}
|
||||
|
||||
System.out.println("Starting world " + i);
|
||||
log.info("Starting world {}", i);
|
||||
|
||||
int exprate = YamlConfig.config.worlds.get(i).exp_rate;
|
||||
int mesorate = YamlConfig.config.worlds.get(i).meso_rate;
|
||||
@@ -431,10 +433,10 @@ public class Server {
|
||||
if (canDeploy) {
|
||||
world.setServerMessage(YamlConfig.config.worlds.get(i).server_message);
|
||||
|
||||
System.out.println("Finished loading world " + i + "\r\n");
|
||||
log.info("Finished loading world {}", i);
|
||||
return i;
|
||||
} else {
|
||||
System.out.println("Could not load world " + i + "...\r\n");
|
||||
log.error("Could not load world {}...", i);
|
||||
world.shutdown();
|
||||
return -2;
|
||||
}
|
||||
@@ -815,7 +817,7 @@ public class Server {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
System.out.println("Cosmic v" + ServerConstants.VERSION + " starting up.\r\n");
|
||||
log.info("Cosmic v{} starting up.", ServerConstants.VERSION);
|
||||
|
||||
if (YamlConfig.config.server.SHUTDOWNHOOK) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(shutdown(false)));
|
||||
@@ -853,16 +855,19 @@ public class Server {
|
||||
|
||||
long timeToTake = System.currentTimeMillis();
|
||||
SkillFactory.loadAllSkills();
|
||||
System.out.println("Skills loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds");
|
||||
final double skillLoadTime = (System.currentTimeMillis() - timeToTake) / 1000.0;
|
||||
log.info("Skills loaded in {} seconds", skillLoadTime);
|
||||
|
||||
timeToTake = System.currentTimeMillis();
|
||||
|
||||
CashItemFactory.getSpecialCashItems();
|
||||
System.out.println("Items loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds");
|
||||
final double itemLoadTime = (System.currentTimeMillis() - timeToTake) / 1000.0;
|
||||
log.info("Items loaded in {} seconds", itemLoadTime);
|
||||
|
||||
timeToTake = System.currentTimeMillis();
|
||||
MapleQuest.loadAllQuest();
|
||||
System.out.println("Quest loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds\r\n");
|
||||
final double questLoadTime = (System.currentTimeMillis() - timeToTake) / 1000.0;
|
||||
log.info("Quest loaded in {} seconds", questLoadTime);
|
||||
|
||||
NewYearCardRecord.startPendingNewYearCardRequests();
|
||||
|
||||
@@ -882,20 +887,17 @@ public class Server {
|
||||
loadPlayerNpcMapStepFromDb();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();//For those who get errors
|
||||
System.out.println("[SEVERE] Syntax error in 'world.ini'.");
|
||||
log.error("[SEVERE] Syntax error in 'world.ini'.");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
|
||||
if (YamlConfig.config.server.USE_FAMILY_SYSTEM) {
|
||||
timeToTake = System.currentTimeMillis();
|
||||
MapleFamily.loadAllFamilies();
|
||||
System.out.println("Families loaded in " + ((System.currentTimeMillis() - timeToTake) / 1000.0) + " seconds\r\n");
|
||||
final double familyLoadTime = (System.currentTimeMillis() - timeToTake) / 1000.0;
|
||||
log.info("Families loaded in {} seconds", familyLoadTime);
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
|
||||
IoBuffer.setUseDirectBuffer(false); // join IO operations performed by lxconan
|
||||
IoBuffer.setAllocator(new SimpleBufferAllocator());
|
||||
acceptor = new NioSocketAcceptor();
|
||||
@@ -908,9 +910,9 @@ public class Server {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Listening on port 8484\r\n\r\n");
|
||||
log.info("Listening on port 8484");
|
||||
|
||||
System.out.println("Cosmic is now online.\r\n");
|
||||
log.info("Cosmic is now online.");
|
||||
online = true;
|
||||
|
||||
MapleSkillbookInformationProvider.getInstance();
|
||||
|
||||
@@ -21,42 +21,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.server.channel;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import net.server.audit.locks.MonitoredReadLock;
|
||||
import net.server.audit.locks.MonitoredWriteLock;
|
||||
import net.server.audit.locks.factory.MonitoredReadLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredWriteLockFactory;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import config.YamlConfig;
|
||||
import net.server.audit.LockCollector;
|
||||
import net.server.audit.locks.MonitoredLockType;
|
||||
import net.server.audit.locks.MonitoredReentrantLock;
|
||||
import net.server.audit.locks.MonitoredReentrantReadWriteLock;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
|
||||
import constants.game.GameConstants;
|
||||
import net.MapleServerHandler;
|
||||
import net.mina.MapleCodecFactory;
|
||||
|
||||
import net.server.PlayerStorage;
|
||||
import net.server.Server;
|
||||
|
||||
import net.server.world.World;
|
||||
import net.server.audit.LockCollector;
|
||||
import net.server.audit.locks.*;
|
||||
import net.server.audit.locks.factory.MonitoredReadLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredReentrantLockFactory;
|
||||
import net.server.audit.locks.factory.MonitoredWriteLockFactory;
|
||||
import net.server.services.BaseService;
|
||||
import net.server.services.ServicesManager;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import net.server.world.MapleParty;
|
||||
import net.server.world.MaplePartyCharacter;
|
||||
|
||||
import net.server.world.World;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.buffer.SimpleBufferAllocator;
|
||||
import org.apache.mina.core.filterchain.IoFilter;
|
||||
@@ -65,26 +47,25 @@ import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
||||
import org.apache.mina.transport.socket.SocketSessionConfig;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
|
||||
import client.MapleCharacter;
|
||||
import constants.game.GameConstants;
|
||||
import net.server.services.ServicesManager;
|
||||
import net.server.services.BaseService;
|
||||
import net.server.services.type.ChannelServices;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventScriptManager;
|
||||
import server.TimerManager;
|
||||
import server.events.gm.MapleEvent;
|
||||
import server.expeditions.MapleExpedition;
|
||||
import server.expeditions.MapleExpeditionType;
|
||||
import server.maps.MapleHiredMerchant;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleMapManager;
|
||||
import server.maps.MapleMiniDungeon;
|
||||
import server.maps.MapleMiniDungeonInfo;
|
||||
import server.maps.*;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
public final class Channel {
|
||||
private static final Logger log = LoggerFactory.getLogger(Channel.class);
|
||||
|
||||
private int port = 7575;
|
||||
private PlayerStorage players = new PlayerStorage();
|
||||
@@ -173,7 +154,7 @@ public final class Channel {
|
||||
|
||||
services = new ServicesManager(ChannelServices.OVERALL);
|
||||
|
||||
System.out.println(" Channel " + getId() + ": Listening on port " + port);
|
||||
log.info("Channel {}: Listening on port {}", getId(), port);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
package tools;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import config.YamlConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import config.YamlConfig;
|
||||
|
||||
/**
|
||||
* @author Frz (Big Daddy)
|
||||
* @author The Real Spookster - some modifications to this beautiful code
|
||||
* @author Ronan - some connection pool to this beautiful code
|
||||
*/
|
||||
public class DatabaseConnection {
|
||||
private static final Logger log = LoggerFactory.getLogger(DatabaseConnection.class);
|
||||
private static HikariDataSource dataSource;
|
||||
|
||||
public static Connection getConnection() throws SQLException {
|
||||
@@ -61,17 +63,17 @@ public class DatabaseConnection {
|
||||
* @return true if connection to the database initiated successfully, false if not successful
|
||||
*/
|
||||
public static boolean initializeConnectionPool() {
|
||||
System.out.println("Initializing connection pool...");
|
||||
log.info("Initializing connection pool...");
|
||||
final HikariConfig config = getConfig();
|
||||
Instant initStart = Instant.now();
|
||||
try {
|
||||
dataSource = new HikariDataSource(config);
|
||||
long initDuration = Duration.between(initStart, Instant.now()).toMillis();
|
||||
System.out.printf("Connection pool initialized in %d ms%n", initDuration);
|
||||
log.info("Connection pool initialized in {} ms", initDuration);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
long timeout = Duration.between(initStart, Instant.now()).getSeconds();
|
||||
System.err.printf("Failed to initialize database connection pool. Gave up after %d seconds.%n", timeout);
|
||||
log.error("Failed to initialize database connection pool. Gave up after {} seconds.", timeout);
|
||||
}
|
||||
|
||||
// Timed out - failed to initialize
|
||||
|
||||
Reference in New Issue
Block a user