mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
Fix issue with adding the real values of new logging categories
This commit is contained in:
parent
9d3ece8133
commit
3eb102a006
@ -2065,10 +2065,11 @@ uint32 Database::GetGuildIDByCharID(uint32 character_id)
|
|||||||
return atoi(row[0]);
|
return atoi(row[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param log_settings
|
||||||
|
*/
|
||||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
||||||
{
|
{
|
||||||
// log_settings previously initialized to '0' by EQEmuLogSys::LoadLogSettingsDefaults()
|
|
||||||
|
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"log_category_id, "
|
"log_category_id, "
|
||||||
@ -2080,11 +2081,10 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"logsys_categories "
|
"logsys_categories "
|
||||||
"ORDER BY log_category_id";
|
"ORDER BY log_category_id";
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
int log_category_id = 0;
|
||||||
|
|
||||||
int log_category_id = 0;
|
int *categories_in_database = new int[1000];
|
||||||
|
|
||||||
int categories_in_database[1000] = {};
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
log_category_id = atoi(row[0]);
|
log_category_id = atoi(row[0]);
|
||||||
@ -2124,15 +2124,14 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
* Auto inject categories that don't exist in the database...
|
* Auto inject categories that don't exist in the database...
|
||||||
*/
|
*/
|
||||||
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
||||||
if (!categories_in_database[log_index]) {
|
if (categories_in_database[log_index] != 1) {
|
||||||
|
|
||||||
Log(Logs::General,
|
LogInfo(
|
||||||
Logs::Status,
|
"New Log Category [{0}] doesn't exist... Automatically adding to [logsys_categories] table...",
|
||||||
"New Log Category '%s' doesn't exist... Automatically adding to `logsys_categories` table...",
|
|
||||||
Logs::LogCategoryName[log_index]
|
Logs::LogCategoryName[log_index]
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string inject_query = StringFormat(
|
auto inject_query = fmt::format(
|
||||||
"INSERT INTO logsys_categories "
|
"INSERT INTO logsys_categories "
|
||||||
"(log_category_id, "
|
"(log_category_id, "
|
||||||
"log_category_description, "
|
"log_category_description, "
|
||||||
@ -2140,17 +2139,19 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"log_to_file, "
|
"log_to_file, "
|
||||||
"log_to_gmsay) "
|
"log_to_gmsay) "
|
||||||
"VALUES "
|
"VALUES "
|
||||||
"(%i, '%s', %i, %i, %i)",
|
"({0}, '{1}', {2}, {3}, {4})",
|
||||||
log_index,
|
log_index,
|
||||||
EscapeString(Logs::LogCategoryName[log_index]).c_str(),
|
EscapeString(Logs::LogCategoryName[log_index]),
|
||||||
log_settings[log_category_id].log_to_console,
|
std::to_string(log_settings[log_index].log_to_console),
|
||||||
log_settings[log_category_id].log_to_file,
|
std::to_string(log_settings[log_index].log_to_file),
|
||||||
log_settings[log_category_id].log_to_gmsay
|
std::to_string(log_settings[log_index].log_to_gmsay)
|
||||||
);
|
);
|
||||||
|
|
||||||
QueryDatabase(inject_query);
|
QueryDatabase(inject_query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] categories_in_database;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::CountInvSnapshots() {
|
int Database::CountInvSnapshots() {
|
||||||
|
|||||||
@ -123,26 +123,26 @@ void EQEmuLogSys::LoadLogSettingsDefaults()
|
|||||||
/**
|
/**
|
||||||
* Set Defaults
|
* Set Defaults
|
||||||
*/
|
*/
|
||||||
log_settings[Logs::World_Server].log_to_console = Logs::General;
|
log_settings[Logs::World_Server].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Zone_Server].log_to_console = Logs::General;
|
log_settings[Logs::Zone_Server].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::QS_Server].log_to_console = Logs::General;
|
log_settings[Logs::QS_Server].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::UCS_Server].log_to_console = Logs::General;
|
log_settings[Logs::UCS_Server].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Crash].log_to_console = Logs::General;
|
log_settings[Logs::Crash].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::MySQLError].log_to_console = Logs::General;
|
log_settings[Logs::MySQLError].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Login_Server].log_to_console = Logs::General;
|
log_settings[Logs::Login_Server].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Headless_Client].log_to_console = Logs::General;
|
log_settings[Logs::Headless_Client].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::NPCScaling].log_to_gmsay = Logs::General;
|
log_settings[Logs::NPCScaling].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RFC 5424
|
* RFC 5424
|
||||||
*/
|
*/
|
||||||
log_settings[Logs::Emergency].log_to_console = Logs::General;
|
log_settings[Logs::Emergency].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Alert].log_to_console = Logs::General;
|
log_settings[Logs::Alert].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Critical].log_to_console = Logs::General;
|
log_settings[Logs::Critical].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Error].log_to_console = Logs::General;
|
log_settings[Logs::Error].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Warning].log_to_console = Logs::General;
|
log_settings[Logs::Warning].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Notice].log_to_console = Logs::General;
|
log_settings[Logs::Notice].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
log_settings[Logs::Info].log_to_console = Logs::General;
|
log_settings[Logs::Info].log_to_console = static_cast<uint8>(Logs::General);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Category enabled status on defaults
|
* Set Category enabled status on defaults
|
||||||
|
|||||||
@ -520,11 +520,10 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"logsys_categories "
|
"logsys_categories "
|
||||||
"ORDER BY log_category_id";
|
"ORDER BY log_category_id";
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
|
int log_category_id = 0;
|
||||||
|
|
||||||
int log_category_id = 0;
|
int *categories_in_database = new int[1000];
|
||||||
|
|
||||||
int categories_in_database[1000] = {};
|
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
log_category_id = atoi(row[0]);
|
log_category_id = atoi(row[0]);
|
||||||
@ -564,15 +563,14 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
* Auto inject categories that don't exist in the database...
|
* Auto inject categories that don't exist in the database...
|
||||||
*/
|
*/
|
||||||
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
||||||
if (!categories_in_database[log_index]) {
|
if (categories_in_database[log_index] != 1) {
|
||||||
|
|
||||||
Log(Logs::General,
|
LogInfo(
|
||||||
Logs::Status,
|
"New Log Category [{0}] doesn't exist... Automatically adding to [logsys_categories] table...",
|
||||||
"New Log Category '%s' doesn't exist... Automatically adding to `logsys_categories` table...",
|
|
||||||
Logs::LogCategoryName[log_index]
|
Logs::LogCategoryName[log_index]
|
||||||
);
|
);
|
||||||
|
|
||||||
std::string inject_query = StringFormat(
|
auto inject_query = fmt::format(
|
||||||
"INSERT INTO logsys_categories "
|
"INSERT INTO logsys_categories "
|
||||||
"(log_category_id, "
|
"(log_category_id, "
|
||||||
"log_category_description, "
|
"log_category_description, "
|
||||||
@ -580,15 +578,17 @@ void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
|||||||
"log_to_file, "
|
"log_to_file, "
|
||||||
"log_to_gmsay) "
|
"log_to_gmsay) "
|
||||||
"VALUES "
|
"VALUES "
|
||||||
"(%i, '%s', %i, %i, %i)",
|
"({0}, '{1}', {2}, {3}, {4})",
|
||||||
log_index,
|
log_index,
|
||||||
EscapeString(Logs::LogCategoryName[log_index]).c_str(),
|
EscapeString(Logs::LogCategoryName[log_index]),
|
||||||
log_settings[log_category_id].log_to_console,
|
std::to_string(log_settings[log_index].log_to_console),
|
||||||
log_settings[log_category_id].log_to_file,
|
std::to_string(log_settings[log_index].log_to_file),
|
||||||
log_settings[log_category_id].log_to_gmsay
|
std::to_string(log_settings[log_index].log_to_gmsay)
|
||||||
);
|
);
|
||||||
|
|
||||||
QueryDatabase(inject_query);
|
QueryDatabase(inject_query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] categories_in_database;
|
||||||
}
|
}
|
||||||
@ -397,44 +397,88 @@ void Database::GeneralQueryReceive(ServerPacket *pack) {
|
|||||||
safe_delete_array(queryBuffer);
|
safe_delete_array(queryBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
|
void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
||||||
|
{
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"log_category_id, "
|
"log_category_id, "
|
||||||
"log_category_description, "
|
"log_category_description, "
|
||||||
"log_to_console, "
|
"log_to_console, "
|
||||||
"log_to_file, "
|
"log_to_file, "
|
||||||
"log_to_gmsay "
|
"log_to_gmsay "
|
||||||
"FROM "
|
"FROM "
|
||||||
"logsys_categories "
|
"logsys_categories "
|
||||||
"ORDER BY log_category_id";
|
"ORDER BY log_category_id";
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
int log_category = 0;
|
auto results = QueryDatabase(query);
|
||||||
LogSys.file_logs_enabled = false;
|
int log_category_id = 0;
|
||||||
|
|
||||||
|
int *categories_in_database = new int[1000];
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
log_category = atoi(row[0]);
|
log_category_id = atoi(row[0]);
|
||||||
log_settings[log_category].log_to_console = atoi(row[2]);
|
if (log_category_id <= Logs::None || log_category_id >= Logs::MaxCategoryID) {
|
||||||
log_settings[log_category].log_to_file = atoi(row[3]);
|
continue;
|
||||||
log_settings[log_category].log_to_gmsay = atoi(row[4]);
|
}
|
||||||
|
|
||||||
/* Determine if any output method is enabled for the category
|
log_settings[log_category_id].log_to_console = static_cast<uint8>(atoi(row[2]));
|
||||||
and set it to 1 so it can used to check if category is enabled */
|
log_settings[log_category_id].log_to_file = static_cast<uint8>(atoi(row[3]));
|
||||||
const bool log_to_console = log_settings[log_category].log_to_console > 0;
|
log_settings[log_category_id].log_to_gmsay = static_cast<uint8>(atoi(row[4]));
|
||||||
const bool log_to_file = log_settings[log_category].log_to_file > 0;
|
|
||||||
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0;
|
/**
|
||||||
|
* Determine if any output method is enabled for the category
|
||||||
|
* and set it to 1 so it can used to check if category is enabled
|
||||||
|
*/
|
||||||
|
const bool log_to_console = log_settings[log_category_id].log_to_console > 0;
|
||||||
|
const bool log_to_file = log_settings[log_category_id].log_to_file > 0;
|
||||||
|
const bool log_to_gmsay = log_settings[log_category_id].log_to_gmsay > 0;
|
||||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
||||||
|
|
||||||
if (is_category_enabled)
|
if (is_category_enabled) {
|
||||||
log_settings[log_category].is_category_enabled = 1;
|
log_settings[log_category_id].is_category_enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
This determines whether or not the process needs to actually file log anything.
|
* This determines whether or not the process needs to actually file log anything.
|
||||||
If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open
|
* If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open
|
||||||
*/
|
*/
|
||||||
if (log_settings[log_category].log_to_file > 0){
|
if (log_settings[log_category_id].log_to_file > 0) {
|
||||||
LogSys.file_logs_enabled = true;
|
LogSys.file_logs_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categories_in_database[log_category_id] = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Auto inject categories that don't exist in the database...
|
||||||
|
*/
|
||||||
|
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
||||||
|
if (categories_in_database[log_index] != 1) {
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"New Log Category [{0}] doesn't exist... Automatically adding to [logsys_categories] table...",
|
||||||
|
Logs::LogCategoryName[log_index]
|
||||||
|
);
|
||||||
|
|
||||||
|
auto inject_query = fmt::format(
|
||||||
|
"INSERT INTO logsys_categories "
|
||||||
|
"(log_category_id, "
|
||||||
|
"log_category_description, "
|
||||||
|
"log_to_console, "
|
||||||
|
"log_to_file, "
|
||||||
|
"log_to_gmsay) "
|
||||||
|
"VALUES "
|
||||||
|
"({0}, '{1}', {2}, {3}, {4})",
|
||||||
|
log_index,
|
||||||
|
EscapeString(Logs::LogCategoryName[log_index]),
|
||||||
|
std::to_string(log_settings[log_index].log_to_console),
|
||||||
|
std::to_string(log_settings[log_index].log_to_file),
|
||||||
|
std::to_string(log_settings[log_index].log_to_gmsay)
|
||||||
|
);
|
||||||
|
|
||||||
|
QueryDatabase(inject_query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] categories_in_database;
|
||||||
|
}
|
||||||
102
ucs/database.cpp
102
ucs/database.cpp
@ -581,44 +581,88 @@ void Database::GetFriendsAndIgnore(int charID, std::vector<std::string> &friends
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::LoadLogSettings(EQEmuLogSys::LogSettings* log_settings){
|
void Database::LoadLogSettings(EQEmuLogSys::LogSettings *log_settings)
|
||||||
|
{
|
||||||
std::string query =
|
std::string query =
|
||||||
"SELECT "
|
"SELECT "
|
||||||
"log_category_id, "
|
"log_category_id, "
|
||||||
"log_category_description, "
|
"log_category_description, "
|
||||||
"log_to_console, "
|
"log_to_console, "
|
||||||
"log_to_file, "
|
"log_to_file, "
|
||||||
"log_to_gmsay "
|
"log_to_gmsay "
|
||||||
"FROM "
|
"FROM "
|
||||||
"logsys_categories "
|
"logsys_categories "
|
||||||
"ORDER BY log_category_id";
|
"ORDER BY log_category_id";
|
||||||
auto results = QueryDatabase(query);
|
|
||||||
|
|
||||||
int log_category = 0;
|
auto results = QueryDatabase(query);
|
||||||
LogSys.file_logs_enabled = false;
|
int log_category_id = 0;
|
||||||
|
|
||||||
|
int *categories_in_database = new int[1000];
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
log_category = atoi(row[0]);
|
log_category_id = atoi(row[0]);
|
||||||
log_settings[log_category].log_to_console = atoi(row[2]);
|
if (log_category_id <= Logs::None || log_category_id >= Logs::MaxCategoryID) {
|
||||||
log_settings[log_category].log_to_file = atoi(row[3]);
|
continue;
|
||||||
log_settings[log_category].log_to_gmsay = atoi(row[4]);
|
}
|
||||||
|
|
||||||
/* Determine if any output method is enabled for the category
|
log_settings[log_category_id].log_to_console = static_cast<uint8>(atoi(row[2]));
|
||||||
and set it to 1 so it can used to check if category is enabled */
|
log_settings[log_category_id].log_to_file = static_cast<uint8>(atoi(row[3]));
|
||||||
const bool log_to_console = log_settings[log_category].log_to_console > 0;
|
log_settings[log_category_id].log_to_gmsay = static_cast<uint8>(atoi(row[4]));
|
||||||
const bool log_to_file = log_settings[log_category].log_to_file > 0;
|
|
||||||
const bool log_to_gmsay = log_settings[log_category].log_to_gmsay > 0;
|
/**
|
||||||
|
* Determine if any output method is enabled for the category
|
||||||
|
* and set it to 1 so it can used to check if category is enabled
|
||||||
|
*/
|
||||||
|
const bool log_to_console = log_settings[log_category_id].log_to_console > 0;
|
||||||
|
const bool log_to_file = log_settings[log_category_id].log_to_file > 0;
|
||||||
|
const bool log_to_gmsay = log_settings[log_category_id].log_to_gmsay > 0;
|
||||||
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay;
|
||||||
|
|
||||||
if (is_category_enabled)
|
if (is_category_enabled) {
|
||||||
log_settings[log_category].is_category_enabled = 1;
|
log_settings[log_category_id].is_category_enabled = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
This determines whether or not the process needs to actually file log anything.
|
* This determines whether or not the process needs to actually file log anything.
|
||||||
If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open
|
* If we go through this whole loop and nothing is set to any debug level, there is no point to create a file or keep anything open
|
||||||
*/
|
*/
|
||||||
if (log_settings[log_category].log_to_file > 0){
|
if (log_settings[log_category_id].log_to_file > 0) {
|
||||||
LogSys.file_logs_enabled = true;
|
LogSys.file_logs_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categories_in_database[log_category_id] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto inject categories that don't exist in the database...
|
||||||
|
*/
|
||||||
|
for (int log_index = Logs::AA; log_index != Logs::MaxCategoryID; log_index++) {
|
||||||
|
if (categories_in_database[log_index] != 1) {
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"New Log Category [{0}] doesn't exist... Automatically adding to [logsys_categories] table...",
|
||||||
|
Logs::LogCategoryName[log_index]
|
||||||
|
);
|
||||||
|
|
||||||
|
auto inject_query = fmt::format(
|
||||||
|
"INSERT INTO logsys_categories "
|
||||||
|
"(log_category_id, "
|
||||||
|
"log_category_description, "
|
||||||
|
"log_to_console, "
|
||||||
|
"log_to_file, "
|
||||||
|
"log_to_gmsay) "
|
||||||
|
"VALUES "
|
||||||
|
"({0}, '{1}', {2}, {3}, {4})",
|
||||||
|
log_index,
|
||||||
|
EscapeString(Logs::LogCategoryName[log_index]),
|
||||||
|
std::to_string(log_settings[log_index].log_to_console),
|
||||||
|
std::to_string(log_settings[log_index].log_to_file),
|
||||||
|
std::to_string(log_settings[log_index].log_to_gmsay)
|
||||||
|
);
|
||||||
|
|
||||||
|
QueryDatabase(inject_query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] categories_in_database;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user