simgear/debug/logdelta.*: added logDeltaSet() to allow dynamic control.
This commit is contained in:
parent
284667c18f
commit
687e65fa36
@ -58,17 +58,24 @@ struct logDelta
|
||||
{
|
||||
logDelta()
|
||||
{
|
||||
// We output diagnostics to std::cerr during this startup phase.
|
||||
//
|
||||
const char* items = getenv("SG_LOG_DELTAS");
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::cerr << __FILE__ << ":" << __LINE__ << ": "
|
||||
<< "Parsing $SG_LOG_DELTAS: '" << items << "'"
|
||||
<< "\n";
|
||||
|
||||
update(items);
|
||||
}
|
||||
|
||||
void update(const char* items)
|
||||
{
|
||||
// We output diagnostics to std::cerr.
|
||||
//
|
||||
std::lock_guard<std::mutex> lock( m_mutex);
|
||||
m_cache.clear();
|
||||
m_items.clear();
|
||||
|
||||
std::string text = items;
|
||||
for(;;) {
|
||||
if (text.empty()) break;
|
||||
@ -217,9 +224,9 @@ struct logDelta
|
||||
std::vector<logDeltaItem> m_items;
|
||||
};
|
||||
|
||||
/* log_delta(filename, line, function) returns the logging level delta for the
|
||||
specified line of code. */
|
||||
static logDelta log_delta;
|
||||
/* s_log_delta(filename, line, function) returns the logging level delta for
|
||||
the specified line of code. */
|
||||
static logDelta s_log_delta;
|
||||
|
||||
sgDebugPriority logDeltaAdd(sgDebugPriority priority,
|
||||
const char* file, int line, const char* function,
|
||||
@ -230,7 +237,7 @@ sgDebugPriority logDeltaAdd(sgDebugPriority priority,
|
||||
// key is unreliable and will leak memory.
|
||||
return priority;
|
||||
}
|
||||
int priority_new = (int) priority + log_delta(file, line, function);
|
||||
int priority_new = (int) priority + s_log_delta(file, line, function);
|
||||
|
||||
// Don't cause new popups.
|
||||
if (priority < SG_POPUP && priority_new >= SG_POPUP) {
|
||||
@ -245,3 +252,8 @@ sgDebugPriority logDeltaAdd(sgDebugPriority priority,
|
||||
}
|
||||
return (sgDebugPriority) priority_new;
|
||||
}
|
||||
|
||||
void logDeltaSet(const char* items)
|
||||
{
|
||||
s_log_delta.update(items);
|
||||
}
|
||||
|
@ -43,3 +43,7 @@ decremented by 1.
|
||||
sgDebugPriority logDeltaAdd(sgDebugPriority priority,
|
||||
const char* file, int line, const char* function,
|
||||
bool freeFilename);
|
||||
|
||||
/* Resets deltas. <items> should be a string in same format as $SG_LOG_DELTAS
|
||||
as described above. */
|
||||
void logDeltaSet(const char* items);
|
||||
|
Loading…
Reference in New Issue
Block a user