Skip to content

Commit

Permalink
fix: debug command
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox committed Jan 23, 2024
1 parent 323a2a1 commit f45890b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/api/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,10 @@ void InitBasicEventListeners() {
if (ev.commandContext().getCommandOrigin().getOriginType() == CommandOriginType::DedicatedServer) {
std::string cmd = ev.commandContext().mCommand.erase(0, 1);

if (!ProcessDebugEngine(cmd)) return false;
if (!ProcessDebugEngine(cmd)) {
ev.cancel();
return false;
}
#ifdef LLSE_BACKEND_NODEJS
if (!NodeJsHelper::processConsoleNpmCmd(ev.mCommand)) return false;
#elif defined(LLSE_BACKEND_PYTHON)
Expand All @@ -1383,7 +1386,10 @@ void InitBasicEventListeners() {
bool callbackRes = CallServerCmdCallback(prefix, paras);
IF_LISTENED(EVENT_TYPES::onConsoleCmd) { CallEvent(EVENT_TYPES::onConsoleCmd, String::newString(cmd)); }
IF_LISTENED_END(EVENT_TYPES::onConsoleCmd);
if (!callbackRes) return false;
if (!callbackRes) {
ev.cancel();
return false;
}
} else {
if (isFromOtherEngine) return false;

Expand Down
14 changes: 8 additions & 6 deletions src/main/BuiltinCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ bool ProcessDebugEngine(const std::string& cmd) {
if (cmd == "stop") {
return true;
} else {
auto result = debugEngine->eval(cmd);
PrintValue(std::cout, result);
std::cout << std::endl;
auto result = debugEngine->eval(cmd);
std::ostringstream sout;
PrintValue(sout, result);
logger.info(sout.str());
OUTPUT_DEBUG_SIGN();
}
} catch (Exception& e) {
Expand Down Expand Up @@ -63,9 +64,10 @@ void RegisterDebugCommand() {
if (results["eval"].isSet) {
EngineScope enter(debugEngine);
try {
auto result = debugEngine->eval(results["eval"].getRaw<std::string>());
PrintValue(std::cout, result);
std::cout << std::endl;
auto result = debugEngine->eval(results["eval"].getRaw<std::string>());
std::ostringstream sout;
PrintValue(sout, result);
logger.info(sout.str());
} catch (Exception& e) {
PrintException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#endif

// Global vars
ll::Logger logger("LegacyScript");
ll::Logger logger(LLSE_LOADER_NAME);

extern void LoadDepends();
extern void LoadMain();
Expand Down

0 comments on commit f45890b

Please sign in to comment.