Provides a set of methods and properties that help you debug the execution of your code.
- Note
- Adding a trace listener to the xtd_diagnostics_debug_listeners collection can cause an exception to be thrown while tracing, if a resource used by the trace listener is not available. The conditions and the exception thrown depend on the trace listener and cannot be enumerated in this topic. It may be useful to place calls to the debug methods in try/catch blocks to detect and handle any exceptions from trace listeners.
- Examples
- The following example uses debug to indicate the beginning and the end of a program's execution. The example also uses the debug::indent and debug::unindent methods to distinguish the tracing output.
|
inline_ void | xtd_diagnostics_debug_write (const char *message, const char *category) |
| Writes a category name and message to the trace listeners in the listeners collection. More...
|
|
inline_ void | xtd_diagnostics_debug_write_if (bool condition, const char *message, const char *category) |
| Writes a category name and message to the trace listeners in the Listeners collection if a condition is true. More...
|
|
inline_ void | xtd_diagnostics_debug_write_line (const char *message, const char *category) |
| Writes a category name and message followed by a line terminator to the trace listeners in the listeners collection. More...
|
|
inline_ void | xtd_diagnostics_debug_write_line_if (bool condition, const char *message, const char *category) |
| Writes a category name and message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true. More...
|
|
◆ xtd_diagnostics_debug_get_auto_flush()
bool xtd_diagnostics_debug_get_auto_flush |
( |
| ) |
|
Gets whether xtd_diagnostics_debug_flush should be called on the xtd_diagnostics_debug_Listeners after every write.
- Returns
- true if xtd_diagnostics_debug_flush is called on the xtd_diagnostics_debug_listeners after every write; otherwise, false.
- Library
- xtdc.core
◆ xtd_diagnostics_debug_get_indent_level()
uint32_t xtd_diagnostics_debug_get_indent_level |
( |
| ) |
|
Gets the indent level.
- Returns
- The indent level. The default is zero.
◆ xtd_diagnostics_debug_get_indent_size()
uint32_t xtd_diagnostics_debug_get_indent_size |
( |
| ) |
|
Gets the number of spaces in an indent.
- Returns
- The number of spaces in an indent. The default is four.
◆ xtd_diagnostics_debug_set_auto_flush()
void xtd_diagnostics_debug_set_auto_flush |
( |
bool |
value | ) |
|
Sets whether xtd_diagnostics_debug_flush should be called on the xtd_diagnostics_debug_Listeners after every write.
- Parameters
-
auto_flush | true if xtd_diagnostics_debug_flush is called on the xtd_diagnostics_debug_listeners after every write; otherwise, false. |
- Library
- xtdc.core
◆ xtd_diagnostics_debug_set_indent_level()
void xtd_diagnostics_debug_set_indent_level |
( |
uint32_t |
indent_level | ) |
|
Sets the indent level.
- Parameters
-
indent_level | The indent level. The default is zero. |
◆ xtd_diagnostics_debug_set_indent_size()
void xtd_diagnostics_debug_set_indent_size |
( |
uint32_t |
indent_size | ) |
|
Sets the number of spaces in an indent.
- Parameters
-
indent_size | The number of spaces in an indent. The default is four. |
◆ xtd_diagnostics_debug_write()
inline_ void xtd_diagnostics_debug_write |
( |
const char * |
message, |
|
|
const char * |
category |
|
) |
| |
Writes a category name and message to the trace listeners in the listeners collection.
- Parameters
-
message | A message to write. |
category | A category name used to organize the output. If the value is NULL, this is equivalent to no category. |
- Library
- xtdc.core
◆ xtd_diagnostics_debug_write_if()
inline_ void xtd_diagnostics_debug_write_if |
( |
bool |
condition, |
|
|
const char * |
message, |
|
|
const char * |
category |
|
) |
| |
Writes a category name and message to the trace listeners in the Listeners collection if a condition is true.
- Parameters
-
condition | true to cause a message to be written; otherwise, false. |
message | A message to write. |
category | A category name used to organize the output. If the value is NULL, this is equivalent to no category. |
- Library
- xtdc.core
◆ xtd_diagnostics_debug_write_line()
inline_ void xtd_diagnostics_debug_write_line |
( |
const char * |
message, |
|
|
const char * |
category |
|
) |
| |
Writes a category name and message followed by a line terminator to the trace listeners in the listeners collection.
- Parameters
-
message | A message to write. |
category | A category name used to organize the output. If the value is NULL, this is equivalent to no category. |
- Library
- xtdc.core
◆ xtd_diagnostics_debug_write_line_if()
inline_ void xtd_diagnostics_debug_write_line_if |
( |
bool |
condition, |
|
|
const char * |
message, |
|
|
const char * |
category |
|
) |
| |
Writes a category name and message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true.
- Parameters
-
condition | true to cause a message to be written; otherwise, false. |
message | A message to write. |
category | A category name used to organize the output. If the value is NULL, this is equivalent to no category. |
- Library
- xtdc.core