Apply module debug from main config file when initializing plugins at startup. This allows a module to show debug messages on first init.
git-svn-id: http://voip.null.ro/svn/yate@6574 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
f7df31d03d
commit
39815923a3
|
@ -1333,28 +1333,17 @@ bool Module::setDebug(Message& msg, const String& target)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
NamedCounter* counter = objectsCounter();
|
NamedCounter* counter = objectsCounter();
|
||||||
String str = msg.getValue("line");
|
const String& line = msg[YSTRING("line")];
|
||||||
if (str.startSkip("level")) {
|
debugSet(line);
|
||||||
int dbg = debugLevel();
|
String str = line;
|
||||||
str >> dbg;
|
if (str.startSkip("level"))
|
||||||
if (str == "+") {
|
;
|
||||||
if (debugLevel() > dbg)
|
else if (str == YSTRING("reset")) {
|
||||||
dbg = debugLevel();
|
|
||||||
}
|
|
||||||
else if (str == "-") {
|
|
||||||
if (debugLevel() < dbg)
|
|
||||||
dbg = debugLevel();
|
|
||||||
}
|
|
||||||
debugLevel(dbg);
|
|
||||||
}
|
|
||||||
else if (str == "reset") {
|
|
||||||
debugLevel(TelEngine::debugLevel());
|
|
||||||
debugEnabled(true);
|
|
||||||
if (counter)
|
if (counter)
|
||||||
counter->enable(getObjCounting());
|
counter->enable(getObjCounting());
|
||||||
}
|
}
|
||||||
else if (str.startSkip("objects")) {
|
else if (str.startSkip("objects")) {
|
||||||
bool dbg = (str == "reset") ? getObjCounting() : (counter && counter->enabled());
|
bool dbg = (str == YSTRING("reset")) ? getObjCounting() : (counter && counter->enabled());
|
||||||
str >> dbg;
|
str >> dbg;
|
||||||
if (counter)
|
if (counter)
|
||||||
counter->enable(dbg);
|
counter->enable(dbg);
|
||||||
|
|
|
@ -305,6 +305,7 @@ static int s_exit = -1;
|
||||||
unsigned int Engine::s_congestion = 0;
|
unsigned int Engine::s_congestion = 0;
|
||||||
static Mutex s_congMutex(false,"Congestion");
|
static Mutex s_congMutex(false,"Congestion");
|
||||||
static bool s_debug = true;
|
static bool s_debug = true;
|
||||||
|
static NamedList s_debugInit("");
|
||||||
static bool s_capture = CAPTURE_EVENTS;
|
static bool s_capture = CAPTURE_EVENTS;
|
||||||
static int s_maxevents = 25;
|
static int s_maxevents = 25;
|
||||||
static Mutex s_eventsMutex(false,"EventsList");
|
static Mutex s_eventsMutex(false,"EventsList");
|
||||||
|
@ -1584,6 +1585,9 @@ int Engine::engineInit()
|
||||||
CapturedEvent::capturing(s_capture);
|
CapturedEvent::capturing(s_capture);
|
||||||
s_cfg = configFile(s_cfgfile);
|
s_cfg = configFile(s_cfgfile);
|
||||||
s_cfg.load();
|
s_cfg.load();
|
||||||
|
NamedList* sect = s_cfg.getSection(YSTRING("debug"));
|
||||||
|
if (sect)
|
||||||
|
s_debugInit.copyParams(false,*sect);
|
||||||
s_capture = s_cfg.getBoolValue("general","startevents",s_capture);
|
s_capture = s_cfg.getBoolValue("general","startevents",s_capture);
|
||||||
CapturedEvent::capturing(s_capture);
|
CapturedEvent::capturing(s_capture);
|
||||||
if (s_capture && s_startMsg)
|
if (s_capture && s_startMsg)
|
||||||
|
@ -1859,18 +1863,14 @@ int Engine::run()
|
||||||
if (s_debug) {
|
if (s_debug) {
|
||||||
// one-time sending of debug setup messages
|
// one-time sending of debug setup messages
|
||||||
s_debug = false;
|
s_debug = false;
|
||||||
const NamedList* sect = s_cfg.getSection("debug");
|
for (ObjList* o = s_debugInit.paramList()->skipNull(); o; o = o->skipNext()) {
|
||||||
if (sect) {
|
const NamedString* str = static_cast<NamedString*>(o->get());
|
||||||
unsigned int n = sect->length();
|
if (!(str->name() && *str))
|
||||||
for (unsigned int i = 0; i < n; i++) {
|
continue;
|
||||||
const NamedString* str = sect->getParam(i);
|
Message* m = new Message("engine.debug");
|
||||||
if (!(str && str->name() && *str))
|
m->addParam("module",str->name());
|
||||||
continue;
|
m->addParam("line",*str);
|
||||||
Message* m = new Message("engine.debug");
|
enqueue(m);
|
||||||
m->addParam("module",str->name());
|
|
||||||
m->addParam("line",*str);
|
|
||||||
enqueue(m);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (s_capture) {
|
else if (s_capture) {
|
||||||
|
@ -2278,6 +2278,8 @@ void Engine::initPlugins()
|
||||||
for (; l; l = l->skipNext()) {
|
for (; l; l = l->skipNext()) {
|
||||||
Plugin *p = static_cast<Plugin *>(l->get());
|
Plugin *p = static_cast<Plugin *>(l->get());
|
||||||
TempObjectCounter cnt(p->objectsCounter(),true);
|
TempObjectCounter cnt(p->objectsCounter(),true);
|
||||||
|
if (s_debug)
|
||||||
|
p->debugSet(s_debugInit[p->toString()]);
|
||||||
p->initialize();
|
p->initialize();
|
||||||
if (exiting()) {
|
if (exiting()) {
|
||||||
Output("Initialization aborted, exiting...");
|
Output("Initialization aborted, exiting...");
|
||||||
|
|
|
@ -684,6 +684,31 @@ void DebugEnabler::debugCopy(const DebugEnabler* original)
|
||||||
m_chain = 0;
|
m_chain = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DebugEnabler::debugSet(const char* desc)
|
||||||
|
{
|
||||||
|
if (TelEngine::null(desc))
|
||||||
|
return;
|
||||||
|
String s(desc);
|
||||||
|
if (s.startSkip("level")) {
|
||||||
|
int dbg = debugLevel();
|
||||||
|
s >> dbg;
|
||||||
|
if (s == YSTRING("+")) {
|
||||||
|
if (debugLevel() > dbg)
|
||||||
|
dbg = debugLevel();
|
||||||
|
}
|
||||||
|
else if (s == YSTRING("-")) {
|
||||||
|
if (debugLevel() < dbg)
|
||||||
|
dbg = debugLevel();
|
||||||
|
}
|
||||||
|
debugLevel(dbg);
|
||||||
|
}
|
||||||
|
else if (s == YSTRING("reset")) {
|
||||||
|
debugLevel(TelEngine::debugLevel());
|
||||||
|
debugEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Debugger::Debugger(const char* name, const char* format, ...)
|
Debugger::Debugger(const char* name, const char* format, ...)
|
||||||
: m_name(name), m_level(DebugAll)
|
: m_name(name), m_level(DebugAll)
|
||||||
{
|
{
|
||||||
|
|
|
@ -385,6 +385,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void debugCopy(const DebugEnabler* original = 0);
|
void debugCopy(const DebugEnabler* original = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set debug from description
|
||||||
|
* @param desc Debug description. [level [NNN][+-]] or 'reset'
|
||||||
|
*/
|
||||||
|
void debugSet(const char* desc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Set the current debug name
|
* Set the current debug name
|
||||||
|
|
Loading…
Reference in New Issue