Convert 'LAUNCHER' debugging _log to logger.LogDebugType

This commit is contained in:
Akkadius 2015-01-12 22:50:09 -06:00
parent 4c50025f13
commit 49ecd69b34
3 changed files with 43 additions and 41 deletions

View File

@ -47,13 +47,13 @@ int main(int argc, char *argv[]) {
launcher_name = argv[1];
}
if(launcher_name.length() < 1) {
_log(LAUNCHER__ERROR, "You must specfify a launcher name as the first argument to this program.");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "You must specfify a launcher name as the first argument to this program.");
return 1;
}
_log(LAUNCHER__INIT, "Loading server configuration..");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Loading server configuration..");
if (!EQEmuConfig::LoadConfig()) {
_log(LAUNCHER__ERROR, "Loading server configuration failed.");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Loading server configuration failed.");
return 1;
}
const EQEmuConfig *Config = EQEmuConfig::get();
@ -62,16 +62,16 @@ int main(int argc, char *argv[]) {
* Setup nice signal handlers
*/
if (signal(SIGINT, CatchSignal) == SIG_ERR) {
_log(LAUNCHER__ERROR, "Could not set signal handler");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Could not set signal handler");
return 1;
}
if (signal(SIGTERM, CatchSignal) == SIG_ERR) {
_log(LAUNCHER__ERROR, "Could not set signal handler");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Could not set signal handler");
return 1;
}
#ifndef WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
_log(LAUNCHER__ERROR, "Could not set signal handler");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Could not set signal handler");
return 1;
}
@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
std::map<std::string, ZoneLaunch *> zones;
WorldServer world(zones, launcher_name.c_str(), Config);
if (!world.Connect()) {
_log(LAUNCHER__ERROR, "worldserver.Connect() FAILED! Will retry.");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "worldserver.Connect() FAILED! Will retry.");
}
std::map<std::string, ZoneLaunch *>::iterator zone, zend;
@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
Timer InterserverTimer(INTERSERVER_TIMER); // does auto-reconnect
_log(LAUNCHER__INIT, "Starting main loop...");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Starting main loop...");
// zones["test"] = new ZoneLaunch(&world, "./zone", "dynamic_1");
@ -182,7 +182,7 @@ int main(int argc, char *argv[]) {
void CatchSignal(int sig_num) {
_log(LAUNCHER__STATUS, "Caught signal %d", sig_num);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Caught signal %d", sig_num);
RunLoops = false;
}

View File

@ -17,6 +17,7 @@
*/
#include "../common/debug.h"
#include "../common/eqemu_logsys.h"
#include "../common/servertalk.h"
#include "../common/eqemu_config.h"
#include "../common/string_util.h"
@ -73,14 +74,14 @@ void WorldServer::Process() {
break;
}
case ServerOP_ZAAuthFailed: {
_log(LAUNCHER__ERROR, "World server responded 'Not Authorized', disabling reconnect");
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World server responded 'Not Authorized', disabling reconnect");
pTryReconnect = false;
Disconnect();
break;
}
case ServerOP_LauncherZoneRequest: {
if(pack->size != sizeof(LauncherZoneRequest)) {
_log(LAUNCHER__NET, "Invalid size of LauncherZoneRequest: %d", pack->size);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Invalid size of LauncherZoneRequest: %d", pack->size);
break;
}
const LauncherZoneRequest *lzr = (const LauncherZoneRequest *) pack->pBuffer;
@ -89,9 +90,9 @@ void WorldServer::Process() {
switch(ZoneRequestCommands(lzr->command)) {
case ZR_Start: {
if(m_zones.find(lzr->short_name) != m_zones.end()) {
_log(LAUNCHER__ERROR, "World told us to start zone %s, but it is already running.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to start zone %s, but it is already running.", lzr->short_name);
} else {
_log(LAUNCHER__WORLD, "World told us to start zone %s.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to start zone %s.", lzr->short_name);
ZoneLaunch *l = new ZoneLaunch(this, m_name, lzr->short_name, m_config);
m_zones[lzr->short_name] = l;
}
@ -100,9 +101,9 @@ void WorldServer::Process() {
case ZR_Restart: {
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
if(res == m_zones.end()) {
_log(LAUNCHER__ERROR, "World told us to restart zone %s, but it is not running.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to restart zone %s, but it is not running.", lzr->short_name);
} else {
_log(LAUNCHER__WORLD, "World told us to restart zone %s.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to restart zone %s.", lzr->short_name);
res->second->Restart();
}
break;
@ -110,9 +111,9 @@ void WorldServer::Process() {
case ZR_Stop: {
std::map<std::string, ZoneLaunch *>::iterator res = m_zones.find(lzr->short_name);
if(res == m_zones.end()) {
_log(LAUNCHER__ERROR, "World told us to stop zone %s, but it is not running.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to stop zone %s, but it is not running.", lzr->short_name);
} else {
_log(LAUNCHER__WORLD, "World told us to stop zone %s.", lzr->short_name);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "World told us to stop zone %s.", lzr->short_name);
res->second->Stop();
}
break;
@ -126,7 +127,7 @@ void WorldServer::Process() {
}
default: {
_log(LAUNCHER__NET, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Unknown opcode 0x%x from World of len %d", pack->opcode, pack->size);
break;
}
}

View File

@ -17,6 +17,7 @@
*/
#include "../common/debug.h"
#include "../common/eqemu_logsys.h"
#include "../common/eqemu_config.h"
#include "zone_launch.h"
#include "worldserver.h"
@ -71,7 +72,7 @@ void ZoneLaunch::Start() {
//spec is consumed, even on failure
m_ref = ProcLauncher::get()->Launch(spec);
if(m_ref == ProcLauncher::ProcError) {
_log(LAUNCHER__ERROR, "Failure to launch '%s %s %s'. ", m_config->ZoneExe.c_str(), m_zone.c_str(), m_launcherName);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Failure to launch '%s %s %s'. ", m_config->ZoneExe.c_str(), m_zone.c_str(), m_launcherName);
m_timer.Start(m_config->RestartWait);
return;
}
@ -83,17 +84,17 @@ void ZoneLaunch::Start() {
SendStatus();
_log(LAUNCHER__STATUS, "Zone %s has been started.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s has been started.", m_zone.c_str());
}
void ZoneLaunch::Restart() {
switch(m_state) {
case StateRestartPending:
_log(LAUNCHER__STATUS, "Restart of zone %s requested when a restart is already pending.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Restart of zone %s requested when a restart is already pending.", m_zone.c_str());
break;
case StateStartPending:
//we havent started yet, do nothing
_log(LAUNCHER__STATUS, "Restart of %s before it has started. Ignoring.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Restart of %s before it has started. Ignoring.", m_zone.c_str());
break;
case StateStarted:
//process is running along, kill it off..
@ -101,20 +102,20 @@ void ZoneLaunch::Restart() {
break; //we have no proc ref... cannot stop..
if(!ProcLauncher::get()->Terminate(m_ref, true)) {
//failed to terminate the process, its not likely that it will work if we try again, so give up.
_log(LAUNCHER__ERROR, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
m_state = StateStopped;
break;
}
_log(LAUNCHER__STATUS, "Termination signal sent to zone %s.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Termination signal sent to zone %s.", m_zone.c_str());
m_timer.Start(m_config->TerminateWait);
m_state = StateRestartPending;
break;
case StateStopPending:
_log(LAUNCHER__STATUS, "Restart of zone %s requested when a stop is pending. Ignoring.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Restart of zone %s requested when a stop is pending. Ignoring.", m_zone.c_str());
break;
case StateStopped:
//process is already stopped... nothing to do..
_log(LAUNCHER__STATUS, "Restart requested when zone %s is already stopped.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Restart requested when zone %s is already stopped.", m_zone.c_str());
break;
}
}
@ -123,7 +124,7 @@ void ZoneLaunch::Stop(bool graceful) {
switch(m_state) {
case StateStartPending:
//we havent started yet, transition directly to stopped.
_log(LAUNCHER__STATUS, "Stopping zone %s before it has started.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Stopping zone %s before it has started.", m_zone.c_str());
m_state = StateStopped;
break;
case StateStarted:
@ -133,17 +134,17 @@ void ZoneLaunch::Stop(bool graceful) {
break; //we have no proc ref... cannot stop..
if(!ProcLauncher::get()->Terminate(m_ref, graceful)) {
//failed to terminate the process, its not likely that it will work if we try again, so give up.
_log(LAUNCHER__ERROR, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Failed to terminate zone %s. Giving up and moving to stopped.", m_zone.c_str());
m_state = StateStopped;
break;
}
_log(LAUNCHER__STATUS, "Termination signal sent to zone %s.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Termination signal sent to zone %s.", m_zone.c_str());
m_timer.Start(m_config->TerminateWait);
m_state = StateStopPending;
break;
case StateStopped:
//process is already stopped... nothing to do..
_log(LAUNCHER__STATUS, "Stop requested when zone %s is already stopped.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Stop requested when zone %s is already stopped.", m_zone.c_str());
break;
}
}
@ -163,17 +164,17 @@ bool ZoneLaunch::Process() {
m_timer.Disable();
//actually start up the program
_log(LAUNCHER__STATUS, "Starting zone %s", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Starting zone %s", m_zone.c_str());
Start();
//now update the shared timer to reflect the proper start interval.
if(s_running == 1) {
//we are the first zone started. wait that interval.
_log(LAUNCHER__STATUS, "Waiting %d milliseconds before booting the second zone.", m_config->InitialBootWait);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Waiting %d milliseconds before booting the second zone.", m_config->InitialBootWait);
s_startTimer.Start(m_config->InitialBootWait);
} else {
//just some follow on zone, use that interval.
_log(LAUNCHER__STATUS, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval);
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Waiting %d milliseconds before booting the next zone.", m_config->ZoneBootInterval);
s_startTimer.Start(m_config->ZoneBootInterval);
}
@ -186,7 +187,7 @@ bool ZoneLaunch::Process() {
//waiting for notification that our child has died..
if(m_timer.Check()) {
//we have timed out, try to kill the child again
_log(LAUNCHER__STATUS, "Zone %s refused to die, killing again.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str());
Restart();
}
break;
@ -196,12 +197,12 @@ bool ZoneLaunch::Process() {
//we have timed out, try to kill the child again
m_killFails++;
if(m_killFails > 5) { //should get this number from somewhere..
_log(LAUNCHER__STATUS, "Zone %s refused to die, giving up and acting like its dead.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s refused to die, giving up and acting like its dead.", m_zone.c_str());
m_state = StateStopped;
s_running--;
SendStatus();
} else {
_log(LAUNCHER__STATUS, "Zone %s refused to die, killing again.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s refused to die, killing again.", m_zone.c_str());
Stop(false);
}
}
@ -220,29 +221,29 @@ void ZoneLaunch::OnTerminate(const ProcLauncher::ProcRef &ref, const ProcLaunche
switch(m_state) {
case StateStartPending:
_log(LAUNCHER__STATUS, "Zone %s has gone down before we started it..?? Restart timer started.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s has gone down before we started it..?? Restart timer started.", m_zone.c_str());
m_state = StateStartPending;
m_timer.Start(m_config->RestartWait);
break;
case StateStarted:
//something happened to our happy process...
_log(LAUNCHER__STATUS, "Zone %s has gone down. Restart timer started.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s has gone down. Restart timer started.", m_zone.c_str());
m_state = StateStartPending;
m_timer.Start(m_config->RestartWait);
break;
case StateRestartPending:
//it finally died, start it on up again
_log(LAUNCHER__STATUS, "Zone %s has terminated. Transitioning to starting state.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s has terminated. Transitioning to starting state.", m_zone.c_str());
m_state = StateStartPending;
break;
case StateStopPending:
//it finally died, transition to close.
_log(LAUNCHER__STATUS, "Zone %s has terminated. Transitioning to stopped state.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Zone %s has terminated. Transitioning to stopped state.", m_zone.c_str());
m_state = StateStopped;
break;
case StateStopped:
//we already thought it was stopped... dont care...
_log(LAUNCHER__STATUS, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str());
logger.LogDebugType(EQEmuLogSys::Detail, EQEmuLogSys::Launcher, "Notified of zone %s terminating when we thought it was stopped.", m_zone.c_str());
break;
}