Nasal: expose SG log levels as constants
This avoids the need to use integers as the first argument to logprint() in Nasal, which is confusing. Add global constants LOG_INFO, LOG_WARN, etc.
This commit is contained in:
parent
11fb8b8c84
commit
c78e6fb443
2 changed files with 25 additions and 9 deletions
|
@ -955,6 +955,17 @@ naRef FGNasalSys::cmdArgGhost()
|
|||
return propNodeGhost(_cmdArg);
|
||||
}
|
||||
|
||||
void FGNasalSys::initLogLevelConstants()
|
||||
{
|
||||
hashset(_globals, "LOG_BULK", naNum(SG_BULK));
|
||||
hashset(_globals, "LOG_WARN", naNum(SG_WARN));
|
||||
hashset(_globals, "LOG_DEBUG", naNum(SG_DEBUG));
|
||||
hashset(_globals, "LOG_INFO", naNum(SG_INFO));
|
||||
hashset(_globals, "LOG_ALERT", naNum(SG_ALERT));
|
||||
hashset(_globals, "DEV_WARN", naNum(SG_DEV_WARN));
|
||||
hashset(_globals, "DEV_ALERT", naNum(SG_DEV_ALERT));
|
||||
}
|
||||
|
||||
void FGNasalSys::setCmdArg(SGPropertyNode* aNode)
|
||||
{
|
||||
_cmdArg = aNode;
|
||||
|
@ -983,6 +994,8 @@ void FGNasalSys::init()
|
|||
hashset(_globals, "thread", naInit_thread(_context));
|
||||
hashset(_globals, "utf8", naInit_utf8(_context));
|
||||
|
||||
initLogLevelConstants();
|
||||
|
||||
// Add our custom extension functions:
|
||||
for(i=0; funcs[i].name; i++)
|
||||
hashset(_globals, funcs[i].name,
|
||||
|
|
|
@ -161,6 +161,18 @@ public:
|
|||
simgear::BufferedLogCallback* log() const
|
||||
{ return _log.get(); }
|
||||
|
||||
private:
|
||||
void initLogLevelConstants();
|
||||
|
||||
void loadPropertyScripts();
|
||||
void loadPropertyScripts(SGPropertyNode* n);
|
||||
void loadScriptDirectory(simgear::Dir nasalDir);
|
||||
void addModule(std::string moduleName, simgear::PathList scripts);
|
||||
static void logError(naContext);
|
||||
naRef parse(naContext ctx, const char* filename, const char* buf, int len,
|
||||
std::string& errors);
|
||||
naRef genPropsModule();
|
||||
|
||||
private:
|
||||
//friend class FGNasalScript;
|
||||
friend class FGNasalListener;
|
||||
|
@ -180,15 +192,6 @@ private:
|
|||
|
||||
static int _listenerId;
|
||||
|
||||
void loadPropertyScripts();
|
||||
void loadPropertyScripts(SGPropertyNode* n);
|
||||
void loadScriptDirectory(simgear::Dir nasalDir);
|
||||
void addModule(std::string moduleName, simgear::PathList scripts);
|
||||
static void logError(naContext);
|
||||
naRef parse(naContext ctx, const char* filename, const char* buf, int len,
|
||||
std::string& errors);
|
||||
naRef genPropsModule();
|
||||
|
||||
bool _inited;
|
||||
naContext _context;
|
||||
naRef _globals,
|
||||
|
|
Loading…
Add table
Reference in a new issue