7#ifndef PXR_BASE_TF_DIAGNOSTIC_H
8#define PXR_BASE_TF_DIAGNOSTIC_H
25#include "pxr/base/tf/api.h"
27#if defined(__cplusplus) || defined (doxygen)
30#include "pxr/base/tf/diagnosticHelper.h"
36PXR_NAMESPACE_OPEN_SCOPE
69#define TF_CODING_ERROR(fmt, args)
84#define TF_RUNTIME_ERROR(fmt, args)
92#define TF_FATAL_ERROR(fmt, args)
174#define TF_STATUS(...)
194#define TF_AXIOM(cond)
206#define TF_DEV_AXIOM(cond)
267#define TF_VERIFY(cond [, format, ...])
275#if defined(__cplusplus) || defined(doxygen)
293#define TF_FUNC_NAME() \
294 ([](char const *f, char const *pf) -> TfEternalString { \
295 static TfEternalString const n = \
296 TfEternalString::Immortalize(ArchGetPrettierFunctionName(f, pf)); \
298 }(__ARCH_FUNCTION__, __ARCH_PRETTY_FUNCTION__))
301void Tf_TerminateHandler();
308#ifdef TF_CODING_ERROR
309#undef TF_CODING_ERROR
311#define TF_CODING_ERROR(...) \
312 Tf_PostErrorHelper(TF_CALL_CONTEXT, \
313 TF_DIAGNOSTIC_CODING_ERROR_TYPE, __VA_ARGS__)
315#ifdef TF_FATAL_CODING_ERROR
316#undef TF_FATAL_CODING_ERROR
318#define TF_FATAL_CODING_ERROR \
319 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
320 TF_DIAGNOSTIC_CODING_ERROR_TYPE).IssueFatalError
323#ifdef TF_CODING_WARNING
324#undef TF_CODING_WARNING
326#define TF_CODING_WARNING(...) \
327 Tf_PostWarningHelper(TF_CALL_CONTEXT, \
328 TF_DIAGNOSTIC_CODING_ERROR_TYPE, __VA_ARGS__)
330#ifdef TF_DIAGNOSTIC_WARNING
331#undef TF_DIAGNOSTIC_WARNING
333#define TF_DIAGNOSTIC_WARNING \
334 Tf_DiagnosticHelper(TF_CALL_CONTEXT.Hide(), \
335 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
337#ifdef TF_RUNTIME_ERROR
338#undef TF_RUNTIME_ERROR
340#define TF_RUNTIME_ERROR(...) \
341 Tf_PostErrorHelper(TF_CALL_CONTEXT, \
342 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, __VA_ARGS__)
347#define TF_FATAL_ERROR \
348 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
349 TF_DIAGNOSTIC_FATAL_ERROR_TYPE).IssueFatalError
351#ifdef TF_DIAGNOSTIC_FATAL_ERROR
352#undef TF_DIAGNOSTIC_FATAL_ERROR
354#define TF_DIAGNOSTIC_FATAL_ERROR \
355 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
356 TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE).IssueFatalError
358#ifdef TF_DIAGNOSTIC_NONFATAL_ERROR
359#undef TF_DIAGNOSTIC_NONFATAL_ERROR
361#define TF_DIAGNOSTIC_NONFATAL_ERROR \
362 Tf_DiagnosticHelper(TF_CALL_CONTEXT, \
363 TF_DIAGNOSTIC_WARNING_TYPE).IssueWarning
377#define TF_WARN(...) \
378 Tf_PostWarningHelper(TF_CALL_CONTEXT, __VA_ARGS__)
383#define TF_STATUS(...) \
384 Tf_PostStatusHelper(TF_CALL_CONTEXT, __VA_ARGS__)
389#define TF_ERROR(...) \
390 Tf_PostErrorHelper(TF_CALL_CONTEXT, __VA_ARGS__)
395#define TF_QUIET_ERROR(...) \
396 Tf_PostQuietlyErrorHelper(TF_CALL_CONTEXT, __VA_ARGS__)
399#define TF_VERIFY(cond, ...) \
400 (ARCH_LIKELY(cond) ? true : \
401 Tf_FailedVerifyHelper(TF_CALL_CONTEXT, # cond, \
402 Tf_VerifyStringFormat(__VA_ARGS__)))
406Tf_FailedVerifyHelper(TfCallContext
const &context,
407 char const *condition,
char const *msg);
411Tf_VerifyStringFormat() {
return nullptr; }
430struct Tf_DiagnosticHelper {
431 Tf_DiagnosticHelper(TfCallContext
const &context,
438 TfCallContext
const &GetContext()
const {
return _context; }
441 TF_API
void IssueError(std::string
const &msg)
const;
443 TF_API
void IssueFatalError(
std::
string const &msg) const;
445 TF_API
void IssueWarning(
std::
string const &msg) const;
447 TF_API
void IssueStatus(
std::
string const &msg) const;
451 TfCallContext _context;
470PXR_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.