LibreOffice
LibreOffice 7.4 SDK C/C++ API Reference
Macros
diagnose.h File Reference

Provides simple diagnostic support. More...

#include "sal/config.h"
#include "sal/detail/log.h"
#include "sal/types.h"

Go to the source code of this file.

Macros

#define OSL_DEBUG_LEVEL   0
 
#define OSL_LOG_PREFIX   SAL_DETAIL_WHERE
 
#define OSL_TRACE(...)    SAL_DETAIL_INFO_IF_FORMAT(OSL_DEBUG_LEVEL > 0, "legacy.osl", __VA_ARGS__)
 Prints trace message. More...
 
#define OSL_ASSERT(c)    SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "OSL_ASSERT: %s", #c)
 If cond is false, reports an error. More...
 
#define OSL_ENSURE(c, m)   SAL_DETAIL_WARN_IF_FORMAT(!(c), "legacy.osl", "%s", m)
 If cond is false, reports an error with message msg. More...
 
#define OSL_FAIL(m)   SAL_DETAIL_WARN_IF_FORMAT(sal_True, "legacy.osl", "%s", m)
 Reports an error with message msg unconditionally. More...
 
#define OSL_VERIFY(c)   do { if (!(c)) OSL_ASSERT(0); } while (0)
 Evaluates the expression and if it is false, reports an error. More...
 
#define OSL_PRECOND(c, m)   OSL_ENSURE(c, m)
 Check the precondition of functions. More...
 
#define OSL_POSTCOND(c, m)   OSL_ENSURE(c, m)
 Check the postcondition of functions. More...
 

Detailed Description

Provides simple diagnostic support.

Deprecated:
The facilities provided by this header are deprecated. True assertions (that detect broken program logic) should use standard assert (which aborts if an assertion fails, and is controlled by the standard NDEBUG macro). Logging of warnings (e.g., about malformed input) and traces (e.g., about steps taken while executing some protocol) should use the facilities provided by (C++ only) sal/log.hxx.

Because the assertion macros (OSL_ASSERT, OSL_ENSURE, OSL_FAIL, OSL_PRECOND, and OSL_POSTCOND) have been used for true assertions as well as for logged warnings, they map to SAL_WARN instead of standard assert. OSL_TRACE maps to SAL_INFO.

The functions defined in this header are not intended to be used directly, but through defined macros. The macros can be divided into three categories: assertions, traces and other stuff .-) Their usability depends on the value of OSL_DEBUG_LEVEL macro: assertions are only active if OSL_DEBUG_LEVEL is 1 or greater, traces if OSL_DEBUG_LEVEL is 2 or greater.

Traces: OSL_TRACE(fmt, args...) Prints trace message. The arguments have the same meaning as the arguments of printf.

Macro Definition Documentation

◆ OSL_DEBUG_LEVEL

#define OSL_DEBUG_LEVEL   0

◆ OSL_LOG_PREFIX

#define OSL_LOG_PREFIX   SAL_DETAIL_WHERE

◆ OSL_TRACE

#define OSL_TRACE (   ...)     SAL_DETAIL_INFO_IF_FORMAT(OSL_DEBUG_LEVEL > 0, "legacy.osl", __VA_ARGS__)

Prints trace message.

The arguments have the same meaning as the arguments of printf.