summaryrefslogtreecommitdiff
path: root/src/script/common/c_internal.cpp
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-10-15 01:08:18 -0400
committerkwolekr <kwolekr@minetest.net>2015-10-15 01:14:38 -0400
commit7b8d372947aae232ddf598155e972bb4dda157af (patch)
treee7f4d9913100f392749bb2f65540923e1cbc41dd /src/script/common/c_internal.cpp
parent659922fd30d5ee3d7876b22e4d26b116d1ae2513 (diff)
downloadminetest-7b8d372947aae232ddf598155e972bb4dda157af.tar.gz
minetest-7b8d372947aae232ddf598155e972bb4dda157af.tar.bz2
minetest-7b8d372947aae232ddf598155e972bb4dda157af.zip
Use warningstream for deprecated field messages and refactor log_deprecated
Diffstat (limited to 'src/script/common/c_internal.cpp')
-rw-r--r--src/script/common/c_internal.cpp31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/script/common/c_internal.cpp b/src/script/common/c_internal.cpp
index 14d992df0..073ff1541 100644
--- a/src/script/common/c_internal.cpp
+++ b/src/script/common/c_internal.cpp
@@ -163,35 +163,26 @@ void script_run_callbacks_f(lua_State *L, int nargs,
void log_deprecated(lua_State *L, const std::string &message)
{
static bool configured = false;
- static bool dolog = false;
- static bool doerror = false;
+ static bool do_log = false;
+ static bool do_error = false;
- // performance optimization to not have to read and compare setting for every logline
+ // Only read settings on first call
if (!configured) {
std::string value = g_settings->get("deprecated_lua_api_handling");
if (value == "log") {
- dolog = true;
+ do_log = true;
} else if (value == "error") {
- dolog = true;
- doerror = true;
+ do_log = true;
+ do_error = true;
}
}
- if (doerror) {
- if (L != NULL) {
+ if (do_log) {
+ warningstream << message << std::endl;
+ if (do_error)
script_error(L, LUA_ERRRUN, NULL, NULL);
- } else {
- FATAL_ERROR("Can't do a scripterror for this deprecated message, "
- "so exit completely!");
- }
- }
-
- if (dolog) {
- /* abusing actionstream because of lack of file-only-logged loglevel */
- actionstream << message << std::endl;
- if (L != NULL) {
- actionstream << script_get_backtrace(L) << std::endl;
- }
+ else
+ infostream << script_get_backtrace(L) << std::endl;
}
}