mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-13 19:58:21 +00:00
Merge pull request #150 from OogwayUniverse/script_ignore
This commit is contained in:
commit
81d25dd574
@ -45,6 +45,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("authconfig.ini");
|
dConfig config("authconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(bool(std::stoi(config.GetValue("log_debug_statements"))));
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
std::string mysql_host = config.GetValue("mysql_host");
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
@ -152,11 +153,13 @@ int main(int argc, char** argv) {
|
|||||||
dLogger * SetupLogger() {
|
dLogger * SetupLogger() {
|
||||||
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/AuthServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
|
@ -48,6 +48,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("chatconfig.ini");
|
dConfig config("chatconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(bool(std::stoi(config.GetValue("log_debug_statements"))));
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
std::string mysql_host = config.GetValue("mysql_host");
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
@ -156,14 +157,16 @@ int main(int argc, char** argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
dLogger* SetupLogger() {
|
dLogger * SetupLogger() {
|
||||||
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/ChatServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
dLogger::dLogger(const std::string& outpath, bool logToConsole) {
|
dLogger::dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements) {
|
||||||
m_logToConsole = logToConsole;
|
m_logToConsole = logToConsole;
|
||||||
|
m_logDebugStatements = logDebugStatements;
|
||||||
m_outpath = outpath;
|
m_outpath = outpath;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -24,39 +25,26 @@ dLogger::~dLogger() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::LogBasic(const std::string & message) {
|
void dLogger::vLog(const char* format, va_list args) {
|
||||||
LogBasic(message.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void dLogger::LogBasic(const char * format, ...) {
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm time;
|
struct tm time;
|
||||||
localtime_s(&time, &t);
|
localtime_s(&time, &t);
|
||||||
|
|
||||||
char timeStr[70];
|
char timeStr[70];
|
||||||
|
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
||||||
|
|
||||||
char message[2048];
|
char message[2048];
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf_s(message, format, args);
|
vsprintf_s(message, format, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) std::cout << "[" << "time machine broke" << "] " << message;
|
if (m_logToConsole) std::cout << "[" << timeStr << "] " << message;
|
||||||
mFile << "[" << "time" << "] " << message;
|
mFile << "[" << timeStr << "] " << message;
|
||||||
#else
|
#else
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm * time = localtime(&t);
|
struct tm time;
|
||||||
char timeStr[70];
|
localtime_s(&time, &t);
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
char timeStr[70];
|
||||||
|
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
||||||
char message[2048];
|
char message[2048];
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
vsprintf(message, format, args);
|
vsprintf(message, format, args);
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) {
|
if (m_logToConsole) {
|
||||||
fputs("[", stdout);
|
fputs("[", stdout);
|
||||||
@ -76,62 +64,42 @@ void dLogger::LogBasic(const char * format, ...) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::Log(const char * className, const char * format, ...) {
|
void dLogger::LogBasic(const char * format, ...) {
|
||||||
#ifdef _WIN32
|
|
||||||
time_t t = time(NULL);
|
|
||||||
struct tm time;
|
|
||||||
localtime_s(&time, &t);
|
|
||||||
|
|
||||||
char timeStr[70];
|
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", &time);
|
|
||||||
|
|
||||||
char message[2048];
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsprintf_s(message, format, args);
|
vLog(format, args);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_logToConsole) std::cout << "[" << timeStr << "] [" << className << "]: " << message;
|
void dLogger::LogBasic(const std::string & message) {
|
||||||
mFile << "[" << timeStr << "] [" << className << "]: " << message;
|
LogBasic(message.c_str());
|
||||||
#else
|
}
|
||||||
time_t t = time(NULL);
|
|
||||||
struct tm * time = localtime(&t);
|
void dLogger::Log(const char * className, const char * format, ...) {
|
||||||
char timeStr[70];
|
va_list args;
|
||||||
strftime(timeStr, sizeof(timeStr), "%d-%m-%y %H:%M:%S", time);
|
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||||
|
va_start(args, format);
|
||||||
char message[2048];
|
vLog(log.c_str(), args);
|
||||||
va_list args;
|
va_end(args);
|
||||||
va_start(args, format);
|
|
||||||
vsprintf(message, format, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
if (m_logToConsole) {
|
|
||||||
fputs("[", stdout);
|
|
||||||
fputs(timeStr, stdout);
|
|
||||||
fputs("] ", stdout);
|
|
||||||
fputs("[", stdout);
|
|
||||||
fputs(className, stdout);
|
|
||||||
fputs("]: ", stdout);
|
|
||||||
fputs(message, stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp != NULL) {
|
|
||||||
fputs("[", fp);
|
|
||||||
fputs(timeStr, fp);
|
|
||||||
fputs("] ", fp);
|
|
||||||
fputs("[", fp);
|
|
||||||
fputs(className, fp);
|
|
||||||
fputs("]: ", fp);
|
|
||||||
fputs(message, fp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dLogger::Log(const std::string & className, const std::string & message) {
|
void dLogger::Log(const std::string & className, const std::string & message) {
|
||||||
Log(className.c_str(), message.c_str());
|
Log(className.c_str(), message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dLogger::LogDebug(const char * className, const char * format, ...) {
|
||||||
|
if (!m_logDebugStatements) return;
|
||||||
|
va_list args;
|
||||||
|
std::string log = "[" + std::string(className) + "] " + std::string(format);
|
||||||
|
va_start(args, format);
|
||||||
|
vLog(log.c_str(), args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dLogger::LogDebug(const std::string & className, const std::string & message) {
|
||||||
|
LogDebug(className.c_str(), message.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void dLogger::Flush() {
|
void dLogger::Flush() {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
mFile.flush();
|
mFile.flush();
|
||||||
|
@ -7,21 +7,26 @@
|
|||||||
|
|
||||||
class dLogger {
|
class dLogger {
|
||||||
public:
|
public:
|
||||||
dLogger(const std::string& outpath, bool logToConsole);
|
dLogger(const std::string& outpath, bool logToConsole, bool logDebugStatements);
|
||||||
~dLogger();
|
~dLogger();
|
||||||
|
|
||||||
void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; }
|
void SetLogToConsole(bool logToConsole) { m_logToConsole = logToConsole; }
|
||||||
|
void SetLogDebugStatements(bool logDebugStatements) { m_logDebugStatements = logDebugStatements; }
|
||||||
|
void vLog(const char* format, va_list args);
|
||||||
|
|
||||||
void LogBasic(const std::string& message);
|
void LogBasic(const std::string& message);
|
||||||
void LogBasic(const char* format, ...);
|
void LogBasic(const char* format, ...);
|
||||||
void Log(const char* className, const char* format, ...);
|
void Log(const char* className, const char* format, ...);
|
||||||
void Log(const std::string& className, const std::string& message);
|
void Log(const std::string& className, const std::string& message);
|
||||||
|
void LogDebug(const std::string& className, const std::string& message);
|
||||||
|
void LogDebug(const char* className, const char* format, ...);
|
||||||
|
|
||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
const bool GetIsLoggingToConsole() const { return m_logToConsole; }
|
const bool GetIsLoggingToConsole() const { return m_logToConsole; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_logDebugStatements;
|
||||||
bool m_logToConsole;
|
bool m_logToConsole;
|
||||||
std::string m_outpath;
|
std::string m_outpath;
|
||||||
std::ofstream mFile;
|
std::ofstream mFile;
|
||||||
|
@ -72,6 +72,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("masterconfig.ini");
|
dConfig config("masterconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(bool(std::stoi(config.GetValue("log_debug_statements"))));
|
||||||
|
|
||||||
//Connect to CDClient
|
//Connect to CDClient
|
||||||
try {
|
try {
|
||||||
@ -320,11 +321,13 @@ dLogger* SetupLogger() {
|
|||||||
std::string logPath =
|
std::string logPath =
|
||||||
"./logs/MasterServer_" + std::to_string(time(nullptr)) + ".log";
|
"./logs/MasterServer_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacket(Packet* packet) {
|
void HandlePacket(Packet* packet) {
|
||||||
|
@ -785,7 +785,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
|
|||||||
script = invalidToReturn;
|
script = invalidToReturn;
|
||||||
else if (script == invalidToReturn) {
|
else if (script == invalidToReturn) {
|
||||||
if (scriptName.length() > 0)
|
if (scriptName.length() > 0)
|
||||||
Game::logger->Log("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '" + scriptName + "', but returned InvalidScript.\n");
|
||||||
|
// information not really needed for sys admins but is for developers
|
||||||
|
|
||||||
script = invalidToReturn;
|
script = invalidToReturn;
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ int main(int argc, char** argv) {
|
|||||||
dConfig config("worldconfig.ini");
|
dConfig config("worldconfig.ini");
|
||||||
Game::config = &config;
|
Game::config = &config;
|
||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
|
Game::logger->SetLogDebugStatements(bool(std::stoi(config.GetValue("log_debug_statements"))));
|
||||||
if (config.GetValue("disable_chat") == "1") chatDisabled = true;
|
if (config.GetValue("disable_chat") == "1") chatDisabled = true;
|
||||||
|
|
||||||
// Connect to CDClient
|
// Connect to CDClient
|
||||||
@ -503,11 +504,13 @@ int main(int argc, char** argv) {
|
|||||||
dLogger * SetupLogger(int zoneID, int instanceID) {
|
dLogger * SetupLogger(int zoneID, int instanceID) {
|
||||||
std::string logPath = "./logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log";
|
std::string logPath = "./logs/WorldServer_" + std::to_string(zoneID) + "_" + std::to_string(instanceID) + "_" + std::to_string(time(nullptr)) + ".log";
|
||||||
bool logToConsole = false;
|
bool logToConsole = false;
|
||||||
|
bool logDebugStatements = false;
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
logToConsole = true;
|
logToConsole = true;
|
||||||
|
logDebugStatements = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return new dLogger(logPath, logToConsole);
|
return new dLogger(logPath, logToConsole, logDebugStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandlePacketChat(Packet* packet) {
|
void HandlePacketChat(Packet* packet) {
|
||||||
|
@ -19,6 +19,9 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should ignore playkeys
|
# 0 or 1, should ignore playkeys
|
||||||
# If 1 everyone with an account will be able to login, regardless of if they have a key or not
|
# If 1 everyone with an account will be able to login, regardless of if they have a key or not
|
||||||
dont_use_keys=0
|
dont_use_keys=0
|
||||||
|
@ -19,5 +19,8 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should not compile chat hash map to file
|
# 0 or 1, should not compile chat hash map to file
|
||||||
dont_generate_dcf=0
|
dont_generate_dcf=0
|
||||||
|
@ -32,5 +32,8 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should autostart auth, chat, and char servers
|
# 0 or 1, should autostart auth, chat, and char servers
|
||||||
prestart_servers=1
|
prestart_servers=1
|
||||||
|
@ -20,6 +20,9 @@ max_clients=999
|
|||||||
# 0 or 1, should log to console
|
# 0 or 1, should log to console
|
||||||
log_to_console=1
|
log_to_console=1
|
||||||
|
|
||||||
|
# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation
|
||||||
|
log_debug_statements=0
|
||||||
|
|
||||||
# 0 or 1, should not compile chat hash map to file
|
# 0 or 1, should not compile chat hash map to file
|
||||||
dont_generate_dcf=0
|
dont_generate_dcf=0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user