Fixes dlogger PR

When applied this commit fixes the unix build of the previous dLogger PR.
This commit also fixes backwards compatability with config files.
This commit is contained in:
wincent 2021-12-13 16:57:43 +01:00
parent 81d25dd574
commit 259c236b72
6 changed files with 10 additions and 8 deletions

View File

@ -123,6 +123,9 @@ make_directory(${CMAKE_BINARY_DIR}/res)
# Create a /locale directory # Create a /locale directory
make_directory(${CMAKE_BINARY_DIR}/locale) make_directory(${CMAKE_BINARY_DIR}/locale)
# Create a /logs directory
make_directory(${CMAKE_BINARY_DIR}/logs)
# Copy ini files on first build # Copy ini files on first build
if (NOT EXISTS ${PROJECT_BINARY_DIR}/authconfig.ini) if (NOT EXISTS ${PROJECT_BINARY_DIR}/authconfig.ini)
configure_file( configure_file(

View File

@ -45,7 +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")))); Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
//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");

View File

@ -48,7 +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")))); Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
//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");

View File

@ -39,10 +39,9 @@ void dLogger::vLog(const char* format, va_list args) {
mFile << "[" << timeStr << "] " << message; mFile << "[" << timeStr << "] " << message;
#else #else
time_t t = time(NULL); time_t t = time(NULL);
struct tm time; struct tm * time = localtime(&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];
vsprintf(message, format, args); vsprintf(message, format, args);

View File

@ -72,7 +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")))); Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
//Connect to CDClient //Connect to CDClient
try { try {

View File

@ -136,7 +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")))); Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
if (config.GetValue("disable_chat") == "1") chatDisabled = true; if (config.GetValue("disable_chat") == "1") chatDisabled = true;
// Connect to CDClient // Connect to CDClient