7#ifndef PXR_BASE_TF_DIAGNOSTIC_H
8#define PXR_BASE_TF_DIAGNOSTIC_H
24#include "pxr/base/tf/api.h"
26#if defined(__cplusplus) || defined (doxygen)
29#include "pxr/base/tf/diagnosticHelper.h"
35PXR_NAMESPACE_OPEN_SCOPE
68#define TF_CODING_ERROR(fmt, args)
83#define TF_RUNTIME_ERROR(fmt, args)
91#define TF_FATAL_ERROR(fmt, args)
173#define TF_STATUS(...)
193#define TF_AXIOM(cond)
205#define TF_DEV_AXIOM(cond)
266#define TF_VERIFY(cond [, format, ...])
274#if defined(__cplusplus) || defined(doxygen)
292#define TF_FUNC_NAME() \
293 ArchGetPrettierFunctionName(__ARCH_FUNCTION__, __ARCH_PRETTY_FUNCTION__)
295void Tf_TerminateHandler();
302#ifdef TF_CODING_ERROR
303#undef TF_CODING_ERROR
305#define TF_CODING_ERROR(...) \
306 Tf_PostErrorHelper(TF_CALL_CONTEXT, \
307 TF_DIAGNOSTIC_CODING_ERROR_TYPE, __VA_ARGS__)
309#ifdef TF_FATAL_CODING_ERROR
310#undef TF_FATAL_CODING_ERROR
312#define TF_FATAL_CODING_ERROR \
313 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
314 TF_DIAGNOSTIC_CODING_ERROR_TYPE).IssueFatalError
317#ifdef TF_CODING_WARNING
318#undef TF_CODING_WARNING
320#define TF_CODING_WARNING(...) \
321 Tf_PostWarningHelper(TF_CALL_CONTEXT, \
322 TF_DIAGNOSTIC_CODING_ERROR_TYPE, __VA_ARGS__)
324#ifdef TF_DIAGNOSTIC_WARNING
325#undef TF_DIAGNOSTIC_WARNING
327#define TF_DIAGNOSTIC_WARNING \
328 Tf_DiagnosticHelper(TF_CALL_CONTEXT.Hide(), \
329 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
331#ifdef TF_RUNTIME_ERROR
332#undef TF_RUNTIME_ERROR
334#define TF_RUNTIME_ERROR(...) \
335 Tf_PostErrorHelper(TF_CALL_CONTEXT, \
336 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, __VA_ARGS__)
341#define TF_FATAL_ERROR \
342 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
343 TF_DIAGNOSTIC_FATAL_ERROR_TYPE).IssueFatalError
345#ifdef TF_DIAGNOSTIC_FATAL_ERROR
346#undef TF_DIAGNOSTIC_FATAL_ERROR
348#define TF_DIAGNOSTIC_FATAL_ERROR \
349 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
350 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE).IssueFatalError
352#ifdef TF_DIAGNOSTIC_NONFATAL_ERROR
353#undef TF_DIAGNOSTIC_NONFATAL_ERROR
355#define TF_DIAGNOSTIC_NONFATAL_ERROR \
356 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
357 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
371#define TF_WARN(...) \
372 Tf_PostWarningHelper(TF_CALL_CONTEXT, __VA_ARGS__)
377#define TF_STATUS(...) \
378 Tf_PostStatusHelper(TF_CALL_CONTEXT, __VA_ARGS__)
383#define TF_ERROR(...) \
384 Tf_PostErrorHelper(TF_CALL_CONTEXT, __VA_ARGS__)
389#define TF_QUIET_ERROR(...) \
390 Tf_PostQuietlyErrorHelper(TF_CALL_CONTEXT, __VA_ARGS__)
393#define TF_VERIFY(cond, ...) \
394 (ARCH_LIKELY(cond) ? true : \
395 Tf_FailedVerifyHelper(TF_CALL_CONTEXT, # cond, \
396 Tf_VerifyStringFormat(__VA_ARGS__)))
400Tf_FailedVerifyHelper(TfCallContext
const &context,
401 char const *condition,
char const *msg);
405Tf_VerifyStringFormat() {
return nullptr; }
424struct Tf_DiagnosticHelper {
425 Tf_DiagnosticHelper(TfCallContext
const &context,
432 TfCallContext
const &GetContext()
const {
return _context; }
435 TF_API
void IssueError(std::string
const &msg)
const;
437 TF_API
void IssueFatalError(
std::
string const &msg) const;
439 TF_API
void IssueWarning(
std::
string const &msg) const;
441 TF_API
void IssueStatus(
std::
string const &msg) const;
445 TfCallContext _context;
464PXR_NAMESPACE_CLOSE_SCOPE
#define ARCH_PRINTF_FUNCTION(_fmt, _firstArg)
Macro used to indicate a function takes a printf-like specification.
Stripped down version of diagnostic.h that doesn't define std::string.
TfDiagnosticType
Enum describing various diagnostic conditions.
Define preprocessor function name macros.
void TfSetProgramNameForErrors(std::string const &programName)
Sets program name for reporting errors.
std::string TfGetProgramNameForErrors()
Returns currently set program info.
TF_API void TfInstallTerminateAndCrashHandlers()
(Re)install Tf's crash handler.