Added extmodule support to put a script requested debug message in yate output/logging. Added support to change script's debug level and debug name.
git-svn-id: http://yate.null.ro/svn/yate/trunk@6472 acf43c95-373e-0410-b603-e72c3f656dc1divo
parent
b482039d8a
commit
d81d1f7452
|
@ -212,6 +212,8 @@ setdata (bool) - Attach channel pointer as user data to generated messages<br />
|
|||
reenter (bool) - If this module is allowed to handle messages generated by itself<br />
|
||||
selfwatch (bool) - If this module is allowed to watch messages generated by itself<br />
|
||||
restart (bool) - Restart this global module if it terminates unexpectedly. Must be turned off to allow normal termination<br />
|
||||
debuglevel (int) - Set module debug level<br />
|
||||
debugname (string) - Set module's debug name. One time only set is allowed, subsequent requests will be ignored<br />
|
||||
<b>Engine read-only run parameters:</b><br />
|
||||
engine.version (string,readonly) - Version of the engine, like "2.0.1"<br />
|
||||
engine.release (string,readonly) - Release type and number, like "beta2"<br />
|
||||
|
@ -252,6 +254,15 @@ This is the proper way of logging messages for programs that connect to the
|
|||
socket interface as they may not have the standard error redirected.<br />
|
||||
</p>
|
||||
|
||||
<p><b>Keyword: %%>debug</b><br />
|
||||
%%>debug:<level>:arbitrary escaped string<br />
|
||||
<b>Direction: Application to engine</b><br />
|
||||
The "debug" keyword is used to print arbitrary messages to
|
||||
engine's logging output using specified debug level.<br />
|
||||
This is the proper way of logging messages for programs that connect to the
|
||||
socket interface as they may not have the standard error redirected.<br />
|
||||
</p>
|
||||
|
||||
<p><b>Keyword: %%>connect</b><br />
|
||||
%%>connect:<role>[:<id>][:<type>]<br />
|
||||
<b>Direction: Application to engine</b><br />
|
||||
|
|
|
@ -213,7 +213,7 @@ private:
|
|||
ObjList m_watched;
|
||||
};
|
||||
|
||||
class ExtModReceiver : public MessageReceiver, public Mutex
|
||||
class ExtModReceiver : public MessageReceiver, public Mutex, public DebugEnabler
|
||||
{
|
||||
friend class MsgWatcher;
|
||||
public:
|
||||
|
@ -293,6 +293,7 @@ private:
|
|||
ObjList m_relays;
|
||||
String m_trackName;
|
||||
String m_reason;
|
||||
String m_debugName;
|
||||
};
|
||||
|
||||
class ExtThread : public Thread
|
||||
|
@ -803,6 +804,8 @@ ExtModReceiver::ExtModReceiver(const char* script, const char* args, File* ain,
|
|||
m_maxQueue(s_maxQueue), m_timeout(s_timeout), m_timebomb(s_timebomb), m_restart(false), m_scripted(false),
|
||||
m_buffer(0,DEF_INCOMING_LINE), m_script(script), m_args(args), m_trackName(s_trackName)
|
||||
{
|
||||
debugChain(&__plugin);
|
||||
debugName(m_script);
|
||||
Debug(DebugAll,"ExtModReceiver::ExtModReceiver(\"%s\",\"%s\") [%p]",script,args,this);
|
||||
m_script.trimBlanks();
|
||||
m_args.trimBlanks();
|
||||
|
@ -821,6 +824,8 @@ ExtModReceiver::ExtModReceiver(const char* name, Stream* io, ExtModChan* chan, i
|
|||
m_maxQueue(s_maxQueue), m_timeout(s_timeout), m_timebomb(s_timebomb), m_restart(false), m_scripted(false),
|
||||
m_buffer(0,DEF_INCOMING_LINE), m_script(name), m_args(conn), m_trackName(s_trackName)
|
||||
{
|
||||
debugChain(&__plugin);
|
||||
debugName(m_script);
|
||||
Debug(DebugAll,"ExtModReceiver::ExtModReceiver(\"%s\",%p,%p) [%p]",name,io,chan,this);
|
||||
m_script.trimBlanks();
|
||||
m_args.trimBlanks();
|
||||
|
@ -1224,7 +1229,7 @@ void ExtModReceiver::run()
|
|||
Debug("ExtModule",DebugWarn,"Read error %d on %p [%p]",errno,m_in,this);
|
||||
break;
|
||||
}
|
||||
XDebug(DebugAll,"ExtModReceiver::run() read %d",readsize);
|
||||
XDebug(DebugAll,"ExtModReceiver::run() read %d [%p]",readsize,this);
|
||||
int totalsize = readsize + posinbuf;
|
||||
if (totalsize >= (int)m_buffer.length()) {
|
||||
Debug("ExtModule",DebugWarn,"Overflow reading in buffer of length %u, closing [%p]",
|
||||
|
@ -1504,6 +1509,14 @@ bool ExtModReceiver::processLine(const char* line)
|
|||
Output("%s",id.safe());
|
||||
return false;
|
||||
}
|
||||
else if (id.startSkip("%%>debug:",false)) {
|
||||
int pos = id.find(':');
|
||||
if (pos > 0) {
|
||||
int level = id.substr(0,pos).toInteger(DebugAll,0,DebugTest,DebugAll);
|
||||
Debug(this,level,"%s",String::msgUnescape(id.substr(pos + 1)).safe());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (id.startSkip("%%>setlocal:",false)) {
|
||||
int col = id.find(':');
|
||||
if (col > 0) {
|
||||
|
@ -1622,6 +1635,21 @@ bool ExtModReceiver::processLine(const char* line)
|
|||
ok = val.null();
|
||||
val = Engine::runId();
|
||||
}
|
||||
else if (id == YSTRING("debuglevel")) {
|
||||
ok = true;
|
||||
if (val)
|
||||
debugLevel(val.toInteger(DebugAll,0,DebugTest,DebugAll));
|
||||
val = debugLevel();
|
||||
}
|
||||
else if (id == YSTRING("debugname")) {
|
||||
ok = true;
|
||||
if (val && !m_debugName) {
|
||||
m_debugName = val;
|
||||
debugName(m_debugName);
|
||||
}
|
||||
else
|
||||
val = debugName();
|
||||
}
|
||||
DDebug("ExtModReceiver",DebugAll,"Set '%s'='%s' %s",
|
||||
id.c_str(),val.c_str(),ok ? "ok" : "failed");
|
||||
String out("%%<setlocal:");
|
||||
|
|
Loading…
Reference in New Issue