Skip to content

Commit

Permalink
Fix configuration caching in log_deprecated (#9697)
Browse files Browse the repository at this point in the history
* Fix configuration caching in log_deprecated

The configured variable was never set to true.
I've set the variables to thread_local because the configuration should be reloaded after reentering the world from mainmenu.
  • Loading branch information
HybridDog committed Apr 21, 2020
1 parent 8ef239b commit 4361bfc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/script/common/c_internal.cpp
Expand Up @@ -157,19 +157,20 @@ static void script_log(lua_State *L, const std::string &message,

void log_deprecated(lua_State *L, const std::string &message, int stack_depth)
{
static bool configured = false;
static bool do_log = false;
static bool do_error = false;
static thread_local bool configured = false;
static thread_local bool do_log = false;
static thread_local bool do_error = false;

// Only read settings on first call
if (!configured) {
std::string value = g_settings->get("deprecated_lua_api_handling");
if (value == "log") {
do_log = true;
} else if (value == "error") {
do_log = true;
do_log = true;
do_error = true;
}
configured = true;
}

if (do_log)
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_util.cpp
Expand Up @@ -44,7 +44,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,

// log([level,] text)
// Writes a line to the logger.
// The one-argument version logs to infostream.
// The one-argument version logs to LL_NONE.
// The two-argument version accepts a log level.
// Either the special case "deprecated" for deprecation notices, or any specified in
// Logger::stringToLevel(name).
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_util.h
Expand Up @@ -37,7 +37,7 @@ class ModApiUtil : public ModApiBase

// log([level,] text)
// Writes a line to the logger.
// The one-argument version logs to infostream.
// The one-argument version logs to LL_NONE.
// The two-argument version accepts a log level.
static int l_log(lua_State *L);

Expand Down

0 comments on commit 4361bfc

Please sign in to comment.