MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / LoadLogDatabaseSettings

Method LoadLogDatabaseSettings

common/eqemu_logsys.cpp:617–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings(bool silent_load)
618{
619 InjectTablesIfNotExist();
620
621 auto categories = LogsysCategoriesRepository::GetWhere(
622 *m_database,
623 "TRUE ORDER BY log_category_id"
624 );
625
626 // keep track of categories
627 std::vector<int> db_categories{};
628 db_categories.reserve(categories.size());
629
630 // loop through database categories
631 for (auto &c: categories) {
632 if (c.log_category_id <= Logs::None || c.log_category_id >= Logs::MaxCategoryID) {
633 continue;
634 }
635
636 log_settings[c.log_category_id].log_to_console = static_cast<uint8>(c.log_to_console);
637 log_settings[c.log_category_id].log_to_file = static_cast<uint8>(c.log_to_file);
638 log_settings[c.log_category_id].log_to_gmsay = static_cast<uint8>(c.log_to_gmsay);
639 log_settings[c.log_category_id].log_to_discord = static_cast<uint8>(c.log_to_discord);
640 log_settings[c.log_category_id].discord_webhook_id = c.discord_webhook_id;
641
642 // Determine if any output method is enabled for the category
643 // and set it to 1 so it can used to check if category is enabled
644 const bool log_to_console = log_settings[c.log_category_id].log_to_console > 0;
645 const bool log_to_file = log_settings[c.log_category_id].log_to_file > 0;
646 const bool log_to_gmsay = log_settings[c.log_category_id].log_to_gmsay > 0;
647 const bool log_to_discord = log_settings[c.log_category_id].log_to_discord > 0 &&
648 log_settings[c.log_category_id].discord_webhook_id > 0;
649 const bool is_category_enabled = log_to_console || log_to_file || log_to_gmsay || log_to_discord;
650
651 if (is_category_enabled) {
652 log_settings[c.log_category_id].is_category_enabled = 1;
653 }
654
655 // This determines whether or not the process needs to actually file log anything.
656 // If we go through this whole loop and nothing is set to any debug level, there
657 // is no point to create a file or keep anything open
658 if (log_settings[c.log_category_id].log_to_file > 0) {
659 m_file_logs_enabled = true;
660 }
661
662 db_categories.emplace_back(c.log_category_id);
663 }
664
665 // Auto inject categories that don't exist in the database...
666
667 std::vector<LogsysCategoriesRepository::LogsysCategories> db_categories_to_add{};
668
669 for (int i = Logs::AA; i != Logs::MaxCategoryID; i++) {
670
671 bool is_missing_in_database = std::find(db_categories.begin(), db_categories.end(), i) == db_categories.end();
672 bool is_deprecated_category = Strings::Contains(fmt::format("{}", Logs::LogCategoryName[i]), "Deprecated");
673 if (!is_missing_in_database && is_deprecated_category) {
674 LogInfo(

Callers 14

mainFunction · 0.80
mainFunction · 0.80
ProcessMessageMethod · 0.80
mainFunction · 0.80
HandleMessageMethod · 0.80
mainFunction · 0.80
mainFunction · 0.80
SendServerReloadMethod · 0.80
DatabaseLoadRoutinesMethod · 0.80
ProcessReloadMethod · 0.80
mainFunction · 0.80
command_lootsimFunction · 0.80

Calls 6

findFunction · 0.85
reserveMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected