55#include " ll/api/command/CommandHandle.h"
66#include " ll/api/command/CommandRegistrar.h"
77#include " ll/api/io/Logger.h"
8- #include " ll/api/service/Bedrock.h"
98#include " lse/Entry.h"
9+ #include " lse/api/DirectFormatter.h"
1010#include " mc/server/commands/CommandOutput.h"
1111#include " mc/server/commands/CommandPermissionLevel.h"
1212
1616#include " PythonHelper.h"
1717#endif
1818
19- extern bool isInConsoleDebugMode;
20- extern ScriptEngine* debugEngine;
19+ extern bool isInConsoleDebugMode;
20+ extern ScriptEngine* debugEngine;
21+ std::shared_ptr<ll::io::Logger> debugLogger = ll::io::LoggerRegistry::getInstance().getOrCreate(" LSEDEBUG" );
22+ inline void printConsoleSymbol () { debugLogger->info (" > " ); }
2123
2224bool ProcessDebugEngine (const std::string& cmd) {
2325#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
@@ -26,7 +28,7 @@ bool ProcessDebugEngine(const std::string& cmd) {
2628#endif
2729 if (isInConsoleDebugMode) {
2830 EngineScope enter (debugEngine);
29- auto & logger = lse::LegacyScriptEngine::getInstance ().getSelf ().getLogger ();
31+ auto & logger = lse::LegacyScriptEngine::getInstance ().getSelf ().getLogger ();
3032 try {
3133 if (cmd == " stop" || cmd == LLSE_DEBUG_CMD) {
3234 return true ;
@@ -35,11 +37,11 @@ bool ProcessDebugEngine(const std::string& cmd) {
3537 std::ostringstream sout;
3638 PrintValue (sout, result);
3739 logger.info (sout.str ());
38- std::cout << " > " << std::flush ;
40+ printConsoleSymbol () ;
3941 }
40- } catch (Exception& e ) {
41- ll::error_utils::printException (e, logger);
42- std::cout << " > " << std::flush ;
42+ } catch (... ) {
43+ ll::error_utils::printCurrentException ( logger);
44+ printConsoleSymbol () ;
4345 }
4446 return false ;
4547 }
@@ -51,6 +53,7 @@ struct EngineDebugCommand {
5153};
5254
5355void RegisterDebugCommand () {
56+ debugLogger->setFormatter (ll::makePolymorphic<lse::io::DirectFormatter>());
5457 auto & command = ll::command::CommandRegistrar::getInstance ()
5558 .getOrCreateCommand (LLSE_DEBUG_CMD, " Debug LegacyScriptEngine" , CommandPermissionLevel::Owner);
5659 command.overload <EngineDebugCommand>().optional (" eval" ).execute (
@@ -63,8 +66,8 @@ void RegisterDebugCommand() {
6366 std::ostringstream sout;
6467 PrintValue (sout, result);
6568 output.success (sout.str ());
66- } catch (Exception& e ) {
67- ll::error_utils::printException (e, logger);
69+ } catch (... ) {
70+ ll::error_utils::printCurrentException ( logger);
6871 }
6972 } else {
7073 if (isInConsoleDebugMode) {
@@ -75,7 +78,7 @@ void RegisterDebugCommand() {
7578 // StartDebug
7679 logger.info (" Debug mode begins" );
7780 isInConsoleDebugMode = true ;
78- std::cout << " > " << std::flush ;
81+ printConsoleSymbol () ;
7982 }
8083 }
8184 }
0 commit comments