Skip to content

Commit 05e192f

Browse files
committed
refactor: getSelfPluginInstance -> getSelfModInstance
1 parent 670b958 commit 05e192f

34 files changed

+286
-319
lines changed

src/legacy/api/APIHelp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Local<Value> JsonToValue(std::string jsonStr) {
332332
auto j = ordered_json::parse(jsonStr, nullptr, true, true);
333333
return JsonToValue(j);
334334
} catch (const ordered_json::exception& e) {
335-
lse::getSelfPluginInstance().getLogger().warn(
335+
lse::getSelfModInstance().getLogger().warn(
336336
"{}{}",
337337
"JSON parse error"_tr(),
338338
ll::string_utils::tou8str(e.what())

src/legacy/api/APIHelp.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ std::string ValueKindToString(const ValueKind& kind);
2525
// 输出脚本调用堆栈,API名称,以及插件名
2626
inline void LOG_ERROR_WITH_SCRIPT_INFO(std::string const& func = "", std::string const& msg = "") {
2727
auto e = script::Exception(msg);
28-
lse::getSelfPluginInstance().getLogger().error("script::Exception: {0}\n{1}", e.message(), e.stacktrace());
29-
lse::getSelfPluginInstance().getLogger().error("In API: " + func);
30-
lse::getSelfPluginInstance().getLogger().error("In Plugin: " + getEngineOwnData()->pluginName);
28+
lse::getSelfModInstance().getLogger().error("script::Exception: {0}\n{1}", e.message(), e.stacktrace());
29+
lse::getSelfModInstance().getLogger().error("In API: " + func);
30+
lse::getSelfModInstance().getLogger().error("In Plugin: " + getEngineOwnData()->pluginName);
3131
}
3232

3333
// 参数类型错误输出
@@ -60,12 +60,12 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
6060
// 截获引擎异常
6161
#define CATCH(LOG) \
6262
catch (const Exception& e) { \
63-
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger()); \
63+
ll::error_utils::printException(e, lse::getSelfModInstance().getLogger()); \
6464
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
6565
return Local<Value>(); \
6666
} \
6767
catch (...) { \
68-
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger()); \
68+
ll::error_utils::printCurrentException(lse::getSelfModInstance().getLogger()); \
6969
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
7070
return Local<Value>(); \
7171
}
@@ -94,46 +94,46 @@ inline void LOG_WRONG_ARGS_COUNT(std::string const& func = "") {
9494
// 截获引擎异常_Constructor
9595
#define CATCH_C(LOG) \
9696
catch (const Exception& e) { \
97-
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger()); \
97+
ll::error_utils::printException(e, lse::getSelfModInstance().getLogger()); \
9898
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
9999
return nullptr; \
100100
} \
101101
catch (...) { \
102-
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger()); \
102+
ll::error_utils::printCurrentException(lse::getSelfModInstance().getLogger()); \
103103
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
104104
return nullptr; \
105105
}
106106

107107
// 截获引擎异常_Setter
108108
#define CATCH_S(LOG) \
109109
catch (const Exception& e) { \
110-
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger()); \
110+
ll::error_utils::printException(e, lse::getSelfModInstance().getLogger()); \
111111
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
112112
return; \
113113
} \
114114
catch (...) { \
115-
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger()); \
115+
ll::error_utils::printCurrentException(lse::getSelfModInstance().getLogger()); \
116116
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
117117
return; \
118118
}
119119

120120
// 截获引擎异常_Constructor
121121
#define CATCH_WITHOUT_RETURN(LOG) \
122122
catch (const Exception& e) { \
123-
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger()); \
123+
ll::error_utils::printException(e, lse::getSelfModInstance().getLogger()); \
124124
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
125125
} \
126126
catch (...) { \
127-
ll::error_utils::printCurrentException(lse::getSelfPluginInstance().getLogger()); \
127+
ll::error_utils::printCurrentException(lse::getSelfModInstance().getLogger()); \
128128
LOG_ERROR_WITH_SCRIPT_INFO(__FUNCTION__, LOG); \
129129
}
130130

131131
// 截获回调函数异常
132132
#define CATCH_IN_CALLBACK(callback) \
133133
catch (const Exception& e) { \
134-
ll::error_utils::printException(e, lse::getSelfPluginInstance().getLogger()); \
135-
lse::getSelfPluginInstance().getLogger().error(std::string("In callback for ") + callback); \
136-
lse::getSelfPluginInstance().getLogger().error("In Plugin: " + getEngineOwnData()->pluginName); \
134+
ll::error_utils::printException(e, lse::getSelfModInstance().getLogger()); \
135+
lse::getSelfModInstance().getLogger().error(std::string("In callback for ") + callback); \
136+
lse::getSelfModInstance().getLogger().error("In Plugin: " + getEngineOwnData()->pluginName); \
137137
}
138138

139139
#else
@@ -222,7 +222,7 @@ struct EnumDefineBuilder {
222222
}
223223
return arr;
224224
} catch (const std::exception&) {
225-
lse::getSelfPluginInstance().getLogger().error("Error in " __FUNCTION__);
225+
lse::getSelfModInstance().getLogger().error("Error in " __FUNCTION__);
226226
}
227227
return Local<Value>();
228228
}
@@ -235,7 +235,7 @@ struct EnumDefineBuilder {
235235
}
236236
return obj;
237237
} catch (const std::exception&) {
238-
lse::getSelfPluginInstance().getLogger().error("Error in " __FUNCTION__);
238+
lse::getSelfModInstance().getLogger().error("Error in " __FUNCTION__);
239239
}
240240
return Local<Value>();
241241
}
@@ -250,7 +250,7 @@ struct EnumDefineBuilder {
250250
return String::newString(magic_enum::enum_name(static_cast<Type>(args[0].asNumber().toInt32())));
251251
return Local<Value>();
252252
} catch (const std::exception&) {
253-
lse::getSelfPluginInstance().getLogger().error("Error in " __FUNCTION__);
253+
lse::getSelfModInstance().getLogger().error("Error in " __FUNCTION__);
254254
}
255255
return Local<Value>();
256256
}
@@ -259,7 +259,7 @@ struct EnumDefineBuilder {
259259
try {
260260
return String::newString(typeid(Type).name() + 5);
261261
} catch (const std::exception&) {
262-
lse::getSelfPluginInstance().getLogger().error("Error in " __FUNCTION__);
262+
lse::getSelfModInstance().getLogger().error("Error in " __FUNCTION__);
263263
}
264264
return Local<Value>();
265265
}
@@ -291,7 +291,7 @@ struct EnumDefineBuilder {
291291
try {
292292
return Number::newNumber(static_cast<int>(_val));
293293
} catch (const std::exception&) {
294-
lse::getSelfPluginInstance().getLogger().error("Error in get {}.{}", enumName, _name);
294+
lse::getSelfModInstance().getLogger().error("Error in get {}.{}", enumName, _name);
295295
}
296296
return Local<Value>();
297297
});

src/legacy/api/CommandAPI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Local<Value> McClass::newCommand(const Arguments& args) {
260260
if (registry) {
261261
auto instance = registry->findCommand(name);
262262
if (instance) {
263-
lse::getSelfPluginInstance().getLogger().info(
263+
lse::getSelfModInstance().getLogger().info(
264264
"Runtime command {} already exists, changes will not beapplied except for setOverload!"_tr(name)
265265
);
266266
}
@@ -352,7 +352,7 @@ Local<Value> CommandClass::setEnum(const Arguments& args) {
352352
void onExecute(CommandOrigin const& origin, CommandOutput& output, RuntimeCommand const& runtime) {
353353
std::string commandName = runtime.getCommandName();
354354
if (localShareData->commandCallbacks.find(commandName) == localShareData->commandCallbacks.end()) {
355-
lse::getSelfPluginInstance().getLogger().warn(
355+
lse::getSelfModInstance().getLogger().warn(
356356
"Command {} failed to execute, is the plugin unloaded?"_tr(commandName)
357357
);
358358
return;
@@ -366,7 +366,7 @@ void onExecute(CommandOrigin const& origin, CommandOutput& output, RuntimeComman
366366

367367
auto& registeredCommands = getEngineOwnData()->plugin->registeredCommands;
368368
if (registeredCommands.find(commandName) == registeredCommands.end()) {
369-
lse::getSelfPluginInstance().getLogger().warn("Could not find {} in registered commands."_tr(commandName));
369+
lse::getSelfModInstance().getLogger().warn("Could not find {} in registered commands."_tr(commandName));
370370
return;
371371
}
372372
for (auto& info : registeredCommands[commandName]) {

src/legacy/api/CommandCompatibleAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Local<Value> McClass::regConsoleCmd(const Arguments& args) {
100100

101101
// Helper
102102
bool SendCmdOutput(const std::string& output) {
103-
lse::getSelfPluginInstance().getLogger().info(output);
103+
lse::getSelfModInstance().getLogger().info(output);
104104
return true;
105105
}
106106
// Helper

0 commit comments

Comments
 (0)