Added logging functions to perl/lua apis

This commit is contained in:
Uleat
2019-10-08 20:35:03 -04:00
parent a26227f258
commit 3aed0e257a
2 changed files with 50 additions and 1 deletions
+36
View File
@@ -3580,6 +3580,25 @@ XS(XS__worldwidemarquee) {
XSRETURN_EMPTY;
}
XS(XS__log);
XS(XS__log) {
dXSARGS;
if (items != 1 && items != 2) {
Perl_croak(aTHX_ "Usage: quest::log(uint8 log_category, string message)");
}
else {
uint8 log_category = (uint8)SvIV(ST(0));
std::string log_message = (std::string) SvPV_nolen(ST(1));
if (log_category >= Logs::MaxCategoryID) {
return;
}
Log(Logs::General, log_category, log_message.c_str());
}
XSRETURN_EMPTY;
}
XS(XS__debug);
XS(XS__debug) {
dXSARGS;
@@ -3606,6 +3625,21 @@ XS(XS__debug) {
XSRETURN_EMPTY;
}
XS(XS__log_combat);
XS(XS__log_combat) {
dXSARGS;
if (items != 1) {
Perl_croak(aTHX_ "Usage: quest::log_combat(string message)");
}
else {
std::string log_message = (std::string) SvPV_nolen(ST(0));
Log(Logs::General, Logs::Combat, log_message.c_str());
}
XSRETURN_EMPTY;
}
XS(XS__UpdateZoneHeader);
XS(XS__UpdateZoneHeader) {
dXSARGS;
@@ -3862,6 +3896,8 @@ EXTERN_C XS(boot_quest) {
newXS(strcpy(buf, "itemlink"), XS__itemlink, file);
newXS(strcpy(buf, "lasttaskinset"), XS__lasttaskinset, file);
newXS(strcpy(buf, "level"), XS__level, file);
newXS(strcpy(buf, "log"), XS__log, file);
newXS(strcpy(buf, "log_combat"), XS__log_combat, file);
newXS(strcpy(buf, "me"), XS__me, file);
newXS(strcpy(buf, "modifynpcstat"), XS__ModifyNPCStat, file);
newXS(strcpy(buf, "movegrp"), XS__movegrp, file);