From b52a61c2cb313b1818b77c255c6f411f3d8025ee Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 7 Feb 2013 16:44:24 +0000 Subject: [PATCH] Support logging from Nasal at custom levels. For now, print() still logs at SG_ALERT level. --- src/Scripting/NasalSys.cxx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index ef6440d3d..2c98f6369 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -314,6 +314,27 @@ static naRef f_print(naContext c, naRef me, int argc, naRef* args) return naNum(buf.length()); } +// logprint() extension function. Same as above, all arguments after the +// first argument are concatenated. Argument 0 is the log-level, matching +// sgDebugPriority. +static naRef f_logprint(naContext c, naRef me, int argc, naRef* args) +{ + if (argc < 1) + naRuntimeError(c, "no prioirty argument to logprint()"); + + naRef priority = args[0]; + string buf; + int n = argc; + for(int i=1; i