/src/

span> #include <algorithm> // log([level,] text) // Writes a line to the logger. // The one-argument version logs to infostream. // The two-argument version accepts a log level. // Either the special case "deprecated" for deprecation notices, or any specified in // Logger::stringToLevel(name). int ModApiUtil::l_log(lua_State *L) { NO_MAP_LOCK_REQUIRED; std::string text; LogLevel level = LL_NONE; if (lua_isnone(L, 2)) { text = luaL_checkstring(L, 1); } else { std::string name = luaL_checkstring(L, 1); text = luaL_checkstring(L, 2); if (name == "deprecated") { log_deprecated(L, text); return 0; } level = Logger::stringToLevel(name); if (level == LL_MAX) { warningstream << "Tried to log at unknown level '" << name << "'. Defaulting to \"none\"." << std::endl; level = LL_NONE; } } g_logger.log(level, text); return 0; } // get_us_time() int ModApiUtil::l_get_us_time(lua_State *L) { NO_MAP_LOCK_REQUIRED; lua_pushnumber(L, porting::getTimeUs()); return 1; } #define CHECK_SECURE_SETTING(L, name) \ if (ScriptApiSecurity::isSecure(L) && \ name.compare(0, 7, "secure.") == 0) { \ throw LuaError("Attempt to set secure setting."); \ } // setting_set(name, value) int ModApiUtil::l_setting_set(lua_State *L) { NO_MAP_LOCK_REQUIRED; std::string name = luaL_checkstring(L, 1); std::string value = luaL_checkstring(L, 2); CHECK_SECURE_SETTING(L, name); g_settings->set(name, value); return 0; } // setting_get(name) int ModApiUtil::l_setting_get(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char *name = luaL_checkstring(L, 1); try{