5
5
#include " ll/api/command/CommandHandle.h"
6
6
#include " ll/api/command/CommandRegistrar.h"
7
7
#include " ll/api/io/Logger.h"
8
- #include " ll/api/service/Bedrock.h"
9
8
#include " lse/Entry.h"
9
+ #include " lse/api/DirectFormatter.h"
10
10
#include " mc/server/commands/CommandOutput.h"
11
11
#include " mc/server/commands/CommandPermissionLevel.h"
12
12
16
16
#include " PythonHelper.h"
17
17
#endif
18
18
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 (" > " ); }
21
23
22
24
bool ProcessDebugEngine (const std::string& cmd) {
23
25
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
@@ -26,7 +28,7 @@ bool ProcessDebugEngine(const std::string& cmd) {
26
28
#endif
27
29
if (isInConsoleDebugMode) {
28
30
EngineScope enter (debugEngine);
29
- auto & logger = lse::LegacyScriptEngine::getInstance ().getSelf ().getLogger ();
31
+ auto & logger = lse::LegacyScriptEngine::getInstance ().getSelf ().getLogger ();
30
32
try {
31
33
if (cmd == " stop" || cmd == LLSE_DEBUG_CMD) {
32
34
return true ;
@@ -35,11 +37,11 @@ bool ProcessDebugEngine(const std::string& cmd) {
35
37
std::ostringstream sout;
36
38
PrintValue (sout, result);
37
39
logger.info (sout.str ());
38
- std::cout << " > " << std::flush ;
40
+ printConsoleSymbol () ;
39
41
}
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 () ;
43
45
}
44
46
return false ;
45
47
}
@@ -51,6 +53,7 @@ struct EngineDebugCommand {
51
53
};
52
54
53
55
void RegisterDebugCommand () {
56
+ debugLogger->setFormatter (ll::makePolymorphic<lse::io::DirectFormatter>());
54
57
auto & command = ll::command::CommandRegistrar::getInstance ()
55
58
.getOrCreateCommand (LLSE_DEBUG_CMD, " Debug LegacyScriptEngine" , CommandPermissionLevel::Owner);
56
59
command.overload <EngineDebugCommand>().optional (" eval" ).execute (
@@ -63,8 +66,8 @@ void RegisterDebugCommand() {
63
66
std::ostringstream sout;
64
67
PrintValue (sout, result);
65
68
output.success (sout.str ());
66
- } catch (Exception& e ) {
67
- ll::error_utils::printException (e, logger);
69
+ } catch (... ) {
70
+ ll::error_utils::printCurrentException ( logger);
68
71
}
69
72
} else {
70
73
if (isInConsoleDebugMode) {
@@ -75,7 +78,7 @@ void RegisterDebugCommand() {
75
78
// StartDebug
76
79
logger.info (" Debug mode begins" );
77
80
isInConsoleDebugMode = true ;
78
- std::cout << " > " << std::flush ;
81
+ printConsoleSymbol () ;
79
82
}
80
83
}
81
84
}
0 commit comments