mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-22 11:18:22 -05:00
Feature/new formatting (#547)
* Change to new logging format (closes #542) * Adds a screenshots folder that uses the application startup time * Creating focus nodes for VRT files if the info files contain location information * Fix issue with removing virtual properties * Add a method for returning the cartesian coordinates for a geolocation on a planet
This commit is contained in:
@@ -129,8 +129,11 @@ void ScriptEngine::addLibrary(LuaLibrary library) {
|
||||
if (itf != merged.functions.end()) {
|
||||
// the function with the desired name is already present, but we don't
|
||||
// want to overwrite it
|
||||
LERROR("Lua function '" << fun.name << "' in library '" << library.name <<
|
||||
"' has been defined twice");
|
||||
LERROR(fmt::format(
|
||||
"Lua function '{}' in library '{}' has been defined twice",
|
||||
fun.name,
|
||||
library.name
|
||||
));
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@@ -192,7 +195,7 @@ bool ScriptEngine::runScriptFile(const std::string& filename) {
|
||||
return false;
|
||||
}
|
||||
if (!FileSys.fileExists(filename)) {
|
||||
LERROR("Script with name '" << filename << "' did not exist");
|
||||
LERROR(fmt::format("Script with name '{}' did not exist", filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,32 +230,34 @@ bool ScriptEngine::isLibraryNameAllowed(lua_State* state, const std::string& nam
|
||||
result = true;
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
LERROR("Library name '" << name << "' specifies a boolean");
|
||||
LERROR(fmt::format("Library name '{}' specifies a boolean", name));
|
||||
break;
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
LERROR("Library name '" << name << "' specifies a light user data");
|
||||
LERROR(fmt::format("Library name '{}' specifies a light user data", name));
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
LERROR("Library name '" << name << "' specifies a number");
|
||||
LERROR(fmt::format("Library name '{}' specifies a number", name));
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
LERROR("Library name '" << name << "' specifies a string");
|
||||
LERROR(fmt::format("Library name '{}' specifies a string", name));
|
||||
break;
|
||||
case LUA_TTABLE: {
|
||||
if (hasLibrary(name))
|
||||
LERROR("Library with name '" << name << "' has been registered before");
|
||||
LERROR(fmt::format(
|
||||
"Library with name '{}' has been registered before", name
|
||||
));
|
||||
else
|
||||
LERROR("Library name '" << name << "' specifies a table");
|
||||
LERROR(fmt::format("Library name '{}' specifies a table", name));
|
||||
break;
|
||||
}
|
||||
case LUA_TFUNCTION:
|
||||
LERROR("Library name '" << name << "' specifies a function");
|
||||
LERROR(fmt::format("Library name '{}' specifies a function", name));
|
||||
break;
|
||||
case LUA_TUSERDATA:
|
||||
LERROR("Library name '" << name << "' specifies a user data");
|
||||
LERROR(fmt::format("Library name '{}' specifies a user data", name));
|
||||
break;
|
||||
case LUA_TTHREAD:
|
||||
LERROR("Library name '" << name << "' specifies a thread");
|
||||
LERROR(fmt::format("Library name '{}' specifies a thread", name));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -269,7 +274,7 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library,
|
||||
lua_getfield(state, -1, p.name.c_str());
|
||||
const bool isNil = lua_isnil(state, -1);
|
||||
if (!isNil) {
|
||||
LERROR("Function name '" << p.name << "' was already assigned");
|
||||
LERROR(fmt::format("Function name '{}' was already assigned", p.name));
|
||||
return;
|
||||
}
|
||||
lua_pop(state, 1);
|
||||
@@ -292,9 +297,11 @@ void ScriptEngine::addLibraryFunctions(lua_State* state, LuaLibrary& library,
|
||||
lua_pushstring(state, "documentation");
|
||||
lua_gettable(state, -2);
|
||||
if (lua_isnil(state, -1)) {
|
||||
LERROR(
|
||||
"Module '" << library.name << "' did not provide a documentation in " <<
|
||||
"script file '" << script << "'");
|
||||
LERROR(fmt::format(
|
||||
"Module '{}' did not provide a documentation in script file '{}'",
|
||||
library.name,
|
||||
script
|
||||
));
|
||||
}
|
||||
else {
|
||||
lua_pushnil(state);
|
||||
@@ -592,15 +599,17 @@ bool ScriptEngine::writeLog(const std::string& script) {
|
||||
_logFilename = absPath(_logFilename);
|
||||
_logFileExists = true;
|
||||
|
||||
LDEBUG("Using script log of type '" << _logType <<
|
||||
"' to file '" << _logFilename << "'");
|
||||
LDEBUG(fmt::format(
|
||||
"Using script log of type '{}' to file '{}'", _logType, _logFilename
|
||||
));
|
||||
|
||||
// Test file and clear previous input
|
||||
std::ofstream file(_logFilename, std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
if (!file.good()) {
|
||||
LERROR("Could not open file '" << _logFilename
|
||||
<< "' for logging scripts");
|
||||
LERROR(fmt::format(
|
||||
"Could not open file '{}' for logging scripts", _logFilename
|
||||
));
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -613,7 +622,7 @@ bool ScriptEngine::writeLog(const std::string& script) {
|
||||
// Simple text output to logfile
|
||||
std::ofstream file(_logFilename, std::ofstream::app);
|
||||
if (!file.good()) {
|
||||
LERROR("Could not open file '" << _logFilename << "' for logging scripts");
|
||||
LERROR(fmt::format("Could not open file '{}' for logging scripts", _logFilename));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <ghoul/filesystem/directory.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
|
||||
namespace openspace::luascriptfunctions {
|
||||
|
||||
@@ -96,19 +97,22 @@ int printInternal(ghoul::logging::LogLevel level, lua_State* L) {
|
||||
case LUA_TFUNCTION:
|
||||
case LUA_TUSERDATA:
|
||||
case LUA_TTHREAD:
|
||||
LOGC(level, "print", "Function parameter was of type '" <<
|
||||
luaTypeToString(type) << "'");
|
||||
log(
|
||||
level,
|
||||
"print",
|
||||
fmt::format("Function parameter was of type '{}'", luaTypeToString(type))
|
||||
);
|
||||
break;
|
||||
case LUA_TNIL:
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
LOGC(level, "print", lua_toboolean(L, -1));
|
||||
log(level, "print", fmt::format("{}", lua_toboolean(L, -1)));
|
||||
break;
|
||||
case LUA_TNUMBER:
|
||||
LOGC(level, "print", lua_tonumber(L, -1));
|
||||
log(level, "print", fmt::format("{}", lua_tonumber(L, -1)));
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
LOGC(level, "print", lua_tostring(L, -1));
|
||||
log(level, "print", lua_tostring(L, -1));
|
||||
break;
|
||||
}
|
||||
lua_settop(L, 0);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/time.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
//#include <ghoul/filesystem/filesystem>
|
||||
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
|
||||
@@ -25,12 +25,11 @@
|
||||
#include <openspace/scripting/systemcapabilitiesbinding.h>
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
|
||||
#include <ghoul/fmt.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/misc.h>
|
||||
#include <ghoul/systemcapabilities/generalcapabilitiescomponent.h>
|
||||
#include <ghoul/systemcapabilities/openglcapabilitiescomponent.h>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
using namespace ghoul::lua;
|
||||
@@ -87,7 +86,10 @@ int hasOpenGLVersion(lua_State* L) {
|
||||
|
||||
std::vector<std::string> v = ghoul::tokenizeString(ghoul::lua::checkStringAndPop(L));
|
||||
if (v.size() != 2 && v.size() != 3) {
|
||||
LERRORC("hasVersion", ghoul::lua::errorLocation(L) << "Malformed version string");
|
||||
LERRORC(
|
||||
"hasVersion",
|
||||
fmt::format("{}: Malformed version string", ghoul::lua::errorLocation(L))
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -96,7 +98,9 @@ int hasOpenGLVersion(lua_State* L) {
|
||||
if (!std::isdigit(c)) {
|
||||
LERRORC(
|
||||
"hasVersion",
|
||||
ghoul::lua::errorLocation(L) << "Malformed version string"
|
||||
fmt::format(
|
||||
"{}: Malformed version string", ghoul::lua::errorLocation(L)
|
||||
)
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user