From d81d1f745295dfb3ff1d202708a73126efebd39e Mon Sep 17 00:00:00 2001
From: marian
reenter (bool) - If this module is allowed to handle messages generated by itself
selfwatch (bool) - If this module is allowed to watch messages generated by itself
restart (bool) - Restart this global module if it terminates unexpectedly. Must be turned off to allow normal termination
+debuglevel (int) - Set module debug level
+debugname (string) - Set module's debug name. One time only set is allowed, subsequent requests will be ignored
Engine read-only run parameters:
engine.version (string,readonly) - Version of the engine, like "2.0.1"
engine.release (string,readonly) - Release type and number, like "beta2"
@@ -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.
Keyword: %%>debug
+%%>debug:<level>:arbitrary escaped string
+Direction: Application to engine
+The "debug" keyword is used to print arbitrary messages to
+engine's logging output using specified debug level.
+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.
+
Keyword: %%>connect
%%>connect:<role>[:<id>][:<type>]
Direction: Application to engine
diff --git a/modules/extmodule.cpp b/modules/extmodule.cpp
index 24797aa0..28a2a902 100644
--- a/modules/extmodule.cpp
+++ b/modules/extmodule.cpp
@@ -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("%%