static void SetTraceMask(wxTraceMask ulMask) { ms_ulTraceMask = ulMask; }
// add string trace mask
- static void AddTraceMask(const wxString& str)
- { ms_aTraceMasks.push_back(str); }
+ static void AddTraceMask(const wxString& str);
// add string trace mask
static void RemoveTraceMask(const wxString& str);
// remove all string trace masks
static void ClearTraceMasks();
- // get string trace masks
- static const wxArrayString &GetTraceMasks() { return ms_aTraceMasks; }
+ // get string trace masks: note that this is MT-unsafe if other threads can
+ // call AddTraceMask() concurrently
+ static const wxArrayString& GetTraceMasks() { return ms_aTraceMasks; }
// sets the time stamp string format: this is used as strftime() format
// string for the log targets which add time stamps to the messages; set
// disabled
static wxString ms_timestamp;
+#if wxUSE_THREADS
+ static wxCriticalSection ms_traceCS; // protects ms_aTraceMasks
+#endif
static wxTraceMask ms_ulTraceMask; // controls wxLogTrace behaviour
static wxArrayString ms_aTraceMasks; // more powerful filter for wxLogTrace
};
ms_bAutoCreate = true;
}
+void wxLog::AddTraceMask(const wxString& str)
+{
+ wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
+ ms_aTraceMasks.push_back(str);
+}
+
void wxLog::RemoveTraceMask(const wxString& str)
{
+ wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
int index = ms_aTraceMasks.Index(str);
if ( index != wxNOT_FOUND )
ms_aTraceMasks.RemoveAt((size_t)index);
void wxLog::ClearTraceMasks()
{
+ wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
ms_aTraceMasks.Clear();
}
/*static*/ bool wxLog::IsAllowedTraceMask(const wxString& mask)
{
+ wxCRIT_SECT_LOCKER(lock, ms_traceCS);
+
for ( wxArrayString::iterator it = ms_aTraceMasks.begin(),
en = ms_aTraceMasks.end();
it != en; ++it )
+ {
if ( *it == mask)
return true;
+ }
+
return false;
}
// ----------------------------------------------------------------------------
#if wxUSE_THREADS
-wxCriticalSection wxLog::ms_prevCS;
+wxCriticalSection wxLog::ms_prevCS,
+ wxLog::ms_traceCS;
#endif // wxUSE_THREADS
bool wxLog::ms_bRepetCounting = false;
wxString wxLog::ms_prevString;