Skip to content

Commit 1badab5

Browse files
committed
fix: fix debug engine's logger
1 parent d6b589c commit 1badab5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/lse/Entry.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,28 @@ void loadConfig(const ll::mod::NativeMod& self, Config& cfg) {
154154

155155
void loadDebugEngine(const ll::mod::NativeMod& self) {
156156
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS // NodeJs backend didn't enable debug engine now
157-
auto& scriptEngine = *EngineManager::newEngine();
157+
auto scriptEngine = EngineManager::newEngine();
158158

159159
script::EngineScope engineScope(scriptEngine);
160160

161+
// Init plugin instance for debug engine to prevent something unexpected.
161162
ll::mod::Manifest manifest;
162163
manifest.name = "DebugEngine";
163164
getEngineOwnData()->plugin = std::make_shared<lse::Plugin>(manifest);
165+
// Init logger
166+
getEngineOwnData()->logger = ll::io::LoggerRegistry::getInstance().getOrCreate("DebugEngine");
164167

165-
BindAPIs(&scriptEngine);
168+
BindAPIs(scriptEngine);
166169

167170
// Load BaseLib.
168171
auto baseLibPath = self.getModDir() / "baselib" / BaseLibFileName;
169172
auto baseLibContent = ll::file_utils::readFile(baseLibPath);
170173
if (!baseLibContent) {
171174
throw std::runtime_error("Failed to read BaseLib at {0}"_tr(baseLibPath.string()));
172175
}
173-
scriptEngine.eval(baseLibContent.value());
176+
scriptEngine->eval(baseLibContent.value());
174177

175-
debugEngine = &scriptEngine;
178+
debugEngine = scriptEngine;
176179
#endif
177180
}
178181

0 commit comments

Comments
 (0)