24 #ifndef PXR_BASE_TF_DIAGNOSTIC_MGR_H
25 #define PXR_BASE_TF_DIAGNOSTIC_MGR_H
46 #include <tbb/enumerable_thread_specific.h>
47 #include <tbb/spin_rw_mutex.h>
58 TF_LOG_STACK_TRACE_ON_ERROR,
59 TF_LOG_STACK_TRACE_ON_WARNING,
60 TF_ERROR_MARK_TRACKING,
61 TF_PRINT_ALL_POSTED_ERRORS_TO_STDERR
269 #if !defined(doxygen)
277 const char* errorCodeString)
278 : _context(context), _errorCode(errorCode),
279 _errorCodeString(errorCodeString)
284 void Post(
const char* fmt, ...) const
285 ARCH_PRINTF_FUNCTION(2,3);
288 void PostQuietly(const
char* fmt, ...) const
289 ARCH_PRINTF_FUNCTION(2,3);
292 void Post(const std::
string& msg) const;
296 const std::
string& msg,
300 void PostQuietly(const std::
string& msg,
306 const
char *_errorCodeString;
311 const char *warningCodeString)
312 : _context(context), _warningCode(warningCode),
313 _warningCodeString(warningCodeString)
318 void Post(
const char* fmt, ...) const
319 ARCH_PRINTF_FUNCTION(2,3);
322 void PostQuietly(const
char* fmt, ...) const
323 ARCH_PRINTF_FUNCTION(2,3);
326 void Post(const std::
string &str) const;
330 const std::
string& msg,
334 void PostQuietly(const std::
string& msg) const;
339 const
char *_warningCodeString;
344 const char *statusCodeString)
345 : _context(context), _statusCode(statusCode),
346 _statusCodeString(statusCodeString)
351 void Post(
const char* fmt, ...) const
352 ARCH_PRINTF_FUNCTION(2,3);
355 void PostQuietly(const
char* fmt, ...) const
356 ARCH_PRINTF_FUNCTION(2,3);
359 void Post(const std::
string &str) const;
363 const std::
string& msg,
367 void PostQuietly(const std::
string& msg) const;
372 const
char *_statusCodeString;
378 _statusCode(statusCode)
401 ErrorIterator _GetErrorMarkBegin(
size_t mark,
size_t *nErrors);
404 inline void _CreateErrorMark() { ++_errorMarkCounts.local(); }
407 inline bool _DestroyErrorMark() {
return --_errorMarkCounts.local() == 0; }
411 void _ReportError(
const TfError &err);
423 void _RebuildErrorLogText();
426 void _SetLogInfoForErrors(std::vector<std::string>
const &logText)
const;
430 mutable tbb::enumerable_thread_specific<bool> _reentrantGuard;
433 std::vector<Delegate*> _delegates;
435 mutable tbb::spin_rw_mutex _delegatesMutex;
438 std::atomic<size_t> _nextSerial;
441 tbb::enumerable_thread_specific<ErrorList> _errorList;
448 std::pair<std::vector<std::string>,
449 std::vector<std::string>> texts;
452 void _AppendAndPublishImpl(
bool clear,
455 tbb::enumerable_thread_specific<_LogText> _logText;
459 tbb::enumerable_thread_specific<
460 size_t, tbb::cache_aligned_allocator<size_t>,
461 tbb::ets_key_per_instance> _errorMarkCounts;
474 #endif // PXR_BASE_TF_DIAGNOSTIC_MGR_H
WarningHelper(TfCallContext const &context, TfEnum warningCode, const char *warningCodeString)
virtual TF_API ~Delegate()=0
TF_API ErrorIterator EraseRange(ErrorIterator first, ErrorIterator last)
static TF_API std::string GetCodeName(const TfEnum &code)
Returns the name of the given diagnostic code.
TF_API void PostError(TfEnum errorCode, const char *errorCodeString, TfCallContext const &context, const std::string &commentary, TfDiagnosticInfo info, bool quiet)
TF_API void _UnhandledAbort() const
ErrorIterator GetErrorBegin()
Return an iterator to the beginning of this thread's error list.
GLsizei const GLchar *const * string
ErrorList::iterator ErrorIterator
StatusHelper(TfCallContext const &context, TfEnum statusCode, const char *statusCodeString)
static TF_API This & GetInstance()
Return the singleton instance.
TF_API void PostStatus(TfEnum statusCode, const char *statusCodeString, TfCallContext const &context, std::string const &commentary, TfDiagnosticInfo info, bool quiet) const
PXR_NAMESPACE_OPEN_SCOPE typedef std::any TfDiagnosticInfo
TF_API ErrorIterator EraseError(ErrorIterator i)
TF_API void PostFatal(TfCallContext const &context, TfEnum statusCode, std::string const &msg) const
virtual void IssueError(TfError const &err)=0
Called when a TfError is posted.
TF_API void AppendError(TfError const &e)
std::list< TfError > ErrorList
FatalHelper(TfCallContext const &context, TfEnum statusCode)
virtual void IssueWarning(TfWarning const &warning)=0
Called when a TF_WARNING() is issued.
TF_API void RemoveDelegate(Delegate *delegate)
bool HasActiveErrorMark()
TF_API void AddDelegate(Delegate *delegate)
TF_API void SetQuiet(bool quiet)
virtual void IssueStatus(TfStatus const &status)=0
Called when a TF_STATUS() is issued.
__hostdev__ uint64_t last(uint32_t i) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
TF_API void PostWarning(TfEnum warningCode, const char *warningCodeString, TfCallContext const &context, std::string const &commentary, TfDiagnosticInfo info, bool quiet) const
ErrorIterator GetErrorEnd()
Return an iterator to the end of this thread's error list.
void Post(const std::string &str) const
static TF_API std::string FormatDiagnostic(const TfEnum &code, const TfCallContext &context, const std::string &msg, const TfDiagnosticInfo &info)
#define PXR_NAMESPACE_CLOSE_SCOPE
virtual void IssueFatalError(TfCallContext const &context, std::string const &msg)=0
PXR_NAMESPACE_OPEN_SCOPE TF_DEBUG_CODES(TF_LOG_STACK_TRACE_ON_ERROR, TF_LOG_STACK_TRACE_ON_WARNING, TF_ERROR_MARK_TRACKING, TF_PRINT_ALL_POSTED_ERRORS_TO_STDERR)
TF_API_TEMPLATE_CLASS(TfSingleton< TfDiagnosticMgr >)