mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Quests] Improve Quest Error Handling (#2635)
* Improve Quest Error handling * Update embperl.cpp * Bench test (temp) * Swap log category for benchmark * Swap external process invocation for native Perl eval throw
This commit is contained in:
parent
ae4908b40c
commit
c3cb0b8cdf
@ -140,6 +140,8 @@ EQEmuLogSys *EQEmuLogSys::LoadLogSettingsDefaults()
|
||||
log_settings[Logs::ChecksumVerification].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::CombatRecord].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::Discord].log_to_console = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::QuestErrors].log_to_gmsay = static_cast<uint8>(Logs::General);
|
||||
log_settings[Logs::QuestErrors].log_to_console = static_cast<uint8>(Logs::General);
|
||||
|
||||
/**
|
||||
* RFC 5424
|
||||
@ -254,6 +256,7 @@ uint16 EQEmuLogSys::GetWindowsConsoleColorFromCategory(uint16 log_category)
|
||||
return Console::Color::Yellow;
|
||||
case Logs::MySQLError:
|
||||
case Logs::Error:
|
||||
case Logs::QuestErrors:
|
||||
return Console::Color::LightRed;
|
||||
case Logs::MySQLQuery:
|
||||
case Logs::Debug:
|
||||
@ -281,6 +284,7 @@ std::string EQEmuLogSys::GetLinuxConsoleColorFromCategory(uint16 log_category)
|
||||
case Logs::Normal:
|
||||
return LC_YELLOW;
|
||||
case Logs::MySQLError:
|
||||
case Logs::QuestErrors:
|
||||
case Logs::Warning:
|
||||
case Logs::Critical:
|
||||
case Logs::Error:
|
||||
@ -311,6 +315,7 @@ uint16 EQEmuLogSys::GetGMSayColorFromCategory(uint16 log_category)
|
||||
case Logs::Normal:
|
||||
return Chat::Yellow;
|
||||
case Logs::MySQLError:
|
||||
case Logs::QuestErrors:
|
||||
case Logs::Error:
|
||||
return Chat::Red;
|
||||
case Logs::MySQLQuery:
|
||||
@ -625,7 +630,11 @@ EQEmuLogSys *EQEmuLogSys::LoadLogDatabaseSettings()
|
||||
bool is_missing_in_database = std::find(db_categories.begin(), db_categories.end(), i) == db_categories.end();
|
||||
bool is_deprecated_category = Strings::Contains(fmt::format("{}", Logs::LogCategoryName[i]), "Deprecated");
|
||||
if (!is_missing_in_database && is_deprecated_category) {
|
||||
LogInfo("Logging category [{}] ({}) is now deprecated, deleting from database", Logs::LogCategoryName[i], i);
|
||||
LogInfo(
|
||||
"Logging category [{}] ({}) is now deprecated, deleting from database",
|
||||
Logs::LogCategoryName[i],
|
||||
i
|
||||
);
|
||||
LogsysCategoriesRepository::DeleteOne(*m_database, i);
|
||||
}
|
||||
|
||||
|
||||
@ -136,6 +136,7 @@ namespace Logs {
|
||||
PacketClientServer,
|
||||
PacketServerToServer,
|
||||
Bugs,
|
||||
QuestErrors,
|
||||
MaxCategoryID /* Don't Remove this */
|
||||
};
|
||||
|
||||
@ -229,7 +230,8 @@ namespace Logs {
|
||||
"Packet-S->C",
|
||||
"Packet-C->S",
|
||||
"Packet-S->S",
|
||||
"Bugs"
|
||||
"Bugs",
|
||||
"QuestErrors"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -861,6 +861,16 @@
|
||||
OutF(LogSys, Logs::Detail, Logs::Bugs, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogQuestErrors(message, ...) do {\
|
||||
if (LogSys.IsLogEnabled(Logs::General, Logs::QuestErrors))\
|
||||
OutF(LogSys, Logs::General, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define LogQuestErrorsDetail(message, ...) do {\
|
||||
if (LogSys.IsLogEnabled(Logs::Detail, Logs::QuestErrors))\
|
||||
OutF(LogSys, Logs::Detail, Logs::QuestErrors, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define Log(debug_level, log_category, message, ...) do {\
|
||||
if (LogSys.IsLogEnabled(debug_level, log_category))\
|
||||
LogSys.Out(debug_level, log_category, __FILE__, __func__, __LINE__, message, ##__VA_ARGS__);\
|
||||
|
||||
@ -19,6 +19,9 @@ Eglin
|
||||
#include "embxs.h"
|
||||
#include "../common/features.h"
|
||||
#include "../common/path_manager.h"
|
||||
#include "../common/process/process.h"
|
||||
#include "../common/file.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
#ifndef GvCV_set
|
||||
#define GvCV_set(gv,cv) (GvCV(gv) = (cv))
|
||||
@ -211,6 +214,7 @@ void Embperl::init_eval_file(void)
|
||||
"} else {"
|
||||
// we 'my' $filename,$mtime,$package,$sub to prevent them from changing our state up here.
|
||||
" eval(\"package $package; my(\\$filename,\\$mtime,\\$package,\\$sub); \\$isloaded = 1; require './$filename'; \");"
|
||||
" die $@ if ($@ && $@ !~ /did not return a true value/); "
|
||||
// " print $@ if $@;"
|
||||
/* "local *FH;open FH, $filename or die \"open '$filename' $!\";"
|
||||
"local($/) = undef;my $sub = <FH>;close FH;"
|
||||
@ -229,6 +233,7 @@ int Embperl::eval_file(const char * packagename, const char * filename)
|
||||
std::vector<std::string> args;
|
||||
args.push_back(packagename);
|
||||
args.push_back(filename);
|
||||
|
||||
return dosub("main::eval_file", &args);
|
||||
}
|
||||
|
||||
@ -242,8 +247,7 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
if(args && !args->empty())
|
||||
{
|
||||
if (args && !args->empty()) {
|
||||
for (auto i = args->begin(); i != args->end(); ++i) {
|
||||
XPUSHs(sv_2mortal(newSVpv(i->c_str(), i->length())));
|
||||
}
|
||||
@ -253,13 +257,11 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
count = call_pv(subname, mode);
|
||||
SPAGAIN;
|
||||
|
||||
if(SvTRUE(ERRSV))
|
||||
{
|
||||
if (SvTRUE(ERRSV)) {
|
||||
error = SvPV_nolen(ERRSV);
|
||||
POPs;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
if (count == 1) {
|
||||
SV *ret = POPs;
|
||||
if (SvTYPE(ret) == SVt_IV) {
|
||||
@ -273,8 +275,7 @@ int Embperl::dosub(const char * subname, const std::vector<std::string> * args,
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
|
||||
if(error.length() > 0)
|
||||
{
|
||||
if (error.length() > 0) {
|
||||
std::string errmsg = "Perl runtime error: ";
|
||||
errmsg += SvPVX(ERRSV);
|
||||
throw errmsg;
|
||||
|
||||
@ -135,6 +135,7 @@ public:
|
||||
|
||||
virtual void AddError(std::string error) {
|
||||
LogQuests("{}", error);
|
||||
LogQuestErrors("{}", Strings::Trim(error));
|
||||
|
||||
errors_.push_back(error);
|
||||
if(errors_.size() > 30) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user