xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Types | Static Public Member Functions | List of all members
xtd::diagnostics::debug Class Reference

#include <debug.h>

Definition

Provides a set of methods and properties that help you debug the execution of your code. This class cannot be inherited.

Namespace
xtd::diagnostics
Library
xtd.core
Remarks
You can use the properties and methods in the xtd::diagnostics::debug class to instrument release builds. Instrumentation allows you to monitor the health of your application running in real-life settings. Tracing helps you isolate problems and fix them without disturbing a running system.
This class provides methods to display an assert dialog box, and to emit an assertion that will always fail. This class provides write methods in the following variations: xtd::diagnostics::debug::write, xtd::diagnostics::debug::write_line, xtd::diagnostics::debug::write_if, and xtd::diagnostics::debug::write_line_if.
The xtd::diagnostics::boolean_switch and xtd::diagnostics::trace_switch classes provide means to dynamically control the tracing output. You can modify the values of these switches without recompiling your application. For information on using the configuration file to set a switch, see the xtd::diagnostics::switch class and the xtd::diagnostics::trace_switches topic.
You can customize the tracing output's target by adding xtd::diagnostics::trace_listener instances to or removing instances from the xtd::diagnostics::debug::listeners collection. The xtd::diagnostics::debug::listeners collection is shared by both the xtd::diagnostics::debug and the xtd::diagnostics::trace classes; adding a trace listener to either class adds the listener to both. By default, trace output is emitted using the xtd::diagnostics::default_trace_listener class.
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.
Remarks
You can modify the level of indentation using the xtd::diagnostics::debug::indent method or the xtd::diagnostics::debug::indent_level property. To modify the indent spacing, use the xtd::diagnostics::debug::indent_size property. You can specify whether to automatically flush the output buffer after each write by setting the xtd::diagnostics::debug::auto_flush property to true.
The debug class provides properties to get or set the level of indent, the xtd::diagnostics::debug::indent_size, and whether to xtd::diagnostics::debug::auto_flush after each write.
You must enable debug mode to use a trace listener. The syntax is compiler specific. If you use other than cmake to manage your build, refer to the documentation of your build manager.
  • To enable debug mode with cmake, add the add_definitions(-DDEBUG) command line in the CMakeLists.txt of your project, or you can add #define DEBUG to the top of your file.
To activate your code if DEBUG is defined, you must enclose calls to the methods of Debug in an #if defined(DEBUG) ... #endif block, and add the /DDEBUG option to the compiler command line or add #define DEBUG to the file.
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.

Inherits xtd::static_object.

Public Types

using listener_collection = xtd::diagnostics::trace_listener_collection
 Represents a collection of xtd::diagnostics::trace_listener. More...
 

Static Public Member Functions

static bool auto_flush ()
 Gets whether xtd::diagnostics::debug::flush should be called on the xtd::diagnostics::debug::Listeners after every write. More...
 
static void auto_flush (bool auto_flush)
 Sets whether xtd::diagnostics::debug::flush should be called on the xtd::diagnostics::debug::Listeners after every write. More...
 
static void cassert (bool condition)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void cassert (bool condition, const xtd::diagnostics::stack_frame &stack_frame)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void cassert (bool condition, const xtd::ustring &message)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void cassert (bool condition, const xtd::ustring &message, const xtd::diagnostics::stack_frame &stack_frame)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void fail (const xtd::ustring &message)
 Emits the specified error message. More...
 
static void fail (const xtd::ustring &message, const xtd::ustring &detail_message)
 Emits an error message and a detailed error message. More...
 
static void flush ()
 Flushes the output buffer and causes buffered data to write to the listeners collection. More...
 
static void indent ()
 Increases the current indent_level by one. More...
 
static uint32_t indent_level ()
 Gets the indent level. More...
 
static void indent_level (uint32_t indent_level)
 Sets the indent level. More...
 
static uint32_t indent_size ()
 Gets the number of spaces in an indent. More...
 
static void indent_size (uint32_t indent_size)
 Sets the number of spaces in an indent. More...
 
static listener_collectionlisteners ()
 Gets the collection of listeners that is monitoring the trace output. More...
 
static void listeners (const listener_collection &listeners)
 Sets the collection of listeners that is monitoring the trace output. @paral$m listeners A xtd::diagnostics::debug::listener_collection that represents a collection of type xtd::diagnostics::trace_listener monitoring the trace output. More...
 
template<typename ... args_t>
static void print (const xtd::ustring &format, args_t &&... args)
 Writes a formatted string followed by a line terminator to the trace listeners in the listeners collection. More...
 
static void print (const xtd::ustring &message)
 Writes a message followed by a line terminator to the trace listeners in the listeners collection. More...
 
static bool show_assert_dialog ()
 Gets a value indicating whether the assert dialog should be show. More...
 
static void show_assert_dialog (bool show_assert_dialog)
 Sets a value indicating whether the assert dialog should be show. More...
 
static void trace_error (const xtd::ustring &message)
 Writes an error message to the trace listeners in the Listeners collection using the specified message. More...
 
template<typename ... objects_t>
static void trace_error (const xtd::ustring &message, const objects_t &... args)
 Writes an error message to the trace listeners in the listeners collection using the specified array of objects and formatting information. More...
 
static void trace_information (const xtd::ustring &message)
 Writes an informational message to the trace listeners in the listeners collection using the specified message. More...
 
template<typename ... objects_t>
static void trace_information (const xtd::ustring &message, const objects_t &... args)
 Writes an informational message to the trace listeners in the listeners collection using the specified array of objects and formatting information. More...
 
static void trace_warning (const xtd::ustring &message)
 Writes a warning message to the trace listeners in the listeners collection using the specified message. More...
 
template<typename ... objects_t>
static void trace_warning (const xtd::ustring &message, const objects_t &... args)
 Writes a warning message to the trace listeners in the listeners collection using the specified array of objects and formatting information. More...
 
static void unindent ()
 Decreases the current indent_level by one. More...
 
static bool use_global_lock ()
 Gets a value indicating whether the global lock should be used. More...
 
static void use_global_lock (bool use_global_lock)
 Sets a value indicating whether the global lock should be used. More...
 
template<typename object_t >
static void write (const object_t &message)
 Writes a message to the trace listeners in the listeners collection. More...
 
template<typename object_t >
static void write (const object_t &message, const xtd::ustring &category)
 Writes a category name and message to the trace listeners in the listeners collection. More...
 
template<typename ... args_t>
static void write (const xtd::ustring &format, args_t &&... args)
 Writes a formatted string to the trace listeners in the listeners collection. More...
 
static void write (const xtd::ustring &message)
 Writes a message to the trace listeners in the listeners collection. More...
 
template<typename object_t >
static void write_if (bool condition, const object_t &message)
 Writes a message to the trace listeners in the Listeners collection if a condition is true. More...
 
template<typename object_t >
static void write_if (bool condition, const object_t &message, const xtd::ustring &category)
 Writes a category name and message to the trace listeners in the Listeners collection if a condition is true. More...
 
static void write_if (bool condition, const xtd::ustring &message)
 Writes a message to the trace listeners in the Listeners collection if a condition is true. More...
 
static void write_line ()
 Writes a line terminator to the trace listeners in the listeners collection. More...
 
template<typename object_t >
static void write_line (const object_t &message)
 Writes a message followed by a line terminator to the trace listeners in the listeners collection. More...
 
template<typename object_t >
static void write_line (const object_t &message, const xtd::ustring &category)
 Writes a category name and message followed by a line terminator to the trace listeners in the listeners collection. More...
 
template<typename ... args_t>
static void write_line (const xtd::ustring &format, args_t &&... args)
 Writes a formatted string followed by a line terminator to the trace listeners in the listeners collection. More...
 
static void write_line (const xtd::ustring &message)
 Writes a message followed by a line terminator to the trace listeners in the listeners collection. More...
 
template<typename object_t >
static void write_line_if (bool condition, const object_t &message)
 Writes a message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true. More...
 
template<typename object_t >
static void write_line_if (bool condition, const object_t &message, const xtd::ustring &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...
 
static void write_line_if (bool condition, const xtd::ustring &message)
 Writes a message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true. More...
 

Member Typedef Documentation

◆ listener_collection

Represents a collection of xtd::diagnostics::trace_listener.

Member Function Documentation

◆ auto_flush() [1/2]

static bool xtd::diagnostics::debug::auto_flush ( )
static

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.
Remarks
The default is false.
Flushing the stream will not flush its underlying encoder unless you explicitly call xtd::diagnostics::debug::flush or xtd::diagnostics::debug::close. Setting xtd::diagnostics::debug::auto_flush to true means that data will be flushed from the buffer to the stream.

◆ auto_flush() [2/2]

static void xtd::diagnostics::debug::auto_flush ( bool  auto_flush)
static

Sets whether xtd::diagnostics::debug::flush should be called on the xtd::diagnostics::debug::Listeners after every write.

Parameters
auto_flushtrue if xtd::diagnostics::debug::flush is called on the xtd::diagnostics::debug::listeners after every write; otherwise, false.
Remarks
The default is false.
Flushing the stream will not flush its underlying encoder unless you explicitly call xtd::diagnostics::debug::flush or xtd::diagnostics::debug::close. Setting xtd::diagnostics::debug::auto_flush to true means that data will be flushed from the buffer to the stream.

◆ cassert() [1/4]

static void xtd::diagnostics::debug::cassert ( bool  condition)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
Examples
The following example shows how to use xtd::diagnostics::debug::cassert_ method.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::diagnostics;
int main() {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
debug::cassert_(index > 0);
console::write_line("End application");
}
// This code produces the following output :
//
// > If user clicks assert dialog 'Abort' button:
// Start application
//
// > If user clicks assert dialog 'Retry' button:
// Start application
// > Break the debugger on file debug_cassert.cpp line 12.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
#define cassert_(...)
Checks for a condition; if the condition is false, displays a message box that shows the call stack.
Definition: debug.h:479
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition: assert_dialog_result.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17

◆ cassert() [2/4]

static void xtd::diagnostics::debug::cassert ( bool  condition,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
stack_frameThe stack frame corresponding to the generated assert.

◆ cassert() [3/4]

static void xtd::diagnostics::debug::cassert ( bool  condition,
const xtd::ustring message 
)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
messageThe message to send to the xtd::diagnostics::debug::listeners collection.

◆ cassert() [4/4]

static void xtd::diagnostics::debug::cassert ( bool  condition,
const xtd::ustring message,
const xtd::diagnostics::stack_frame stack_frame 
)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.
messageThe message to send to the xtd::diagnostics::debug::listeners collection.
stack_frameThe stack frame corresponding to the generated assert.

◆ fail() [1/2]

static void xtd::diagnostics::debug::fail ( const xtd::ustring message)
inlinestatic

Emits the specified error message.

Parameters
messageA message to emit.
Remarks
The default behavior is that the xtd::diagnostics::default_trace_listener outputs the message to a message box when the application is running in user interface mode and to the xtd::diagnostics::trace_listener instances in the xtd::diagnostics::debug::listeners collection.
Note
The display of the message box is dependent on the presence of the xtd::diagnostics::default_trace_listener. If the xtd::diagnostics::default_trace_listener is not in the xtd::diagnostics::debug::listeners collection, the message box is not displayed. The xtd::diagnostics::default_trace_listener can be removed by the <clear>, the <erase>, or by calling the clear method on the xtd::diagnostics::debug::listeners property (xtd::diagnostics::trace::listeners().clear()).

◆ fail() [2/2]

static void xtd::diagnostics::debug::fail ( const xtd::ustring message,
const xtd::ustring detail_message 
)
inlinestatic

Emits an error message and a detailed error message.

Parameters
messageA message to emit.
detail_messageA detailed message to emit.
Remarks
The default behavior is that the default_trace_listener outputs the message to a message box when the application is running in user interface mode and to the TraceListener instances in the Listeners collection.
Note
The display of the message box is dependent on the presence of the default_trace_listener. If the default_trace_listener is not in the listeners collection, the message box is not displayed. The default_trace_listener can be removed by the <clear>, the <remove>, or by calling the clear method on the listeners property (xtd::diagnostics::trace::listeners().clear()).

◆ flush()

static void xtd::diagnostics::debug::flush ( )
inlinestatic

Flushes the output buffer and causes buffered data to write to the listeners collection.

◆ indent()

static void xtd::diagnostics::debug::indent ( )
static

Increases the current indent_level by one.

◆ indent_level() [1/2]

static uint32_t xtd::diagnostics::debug::indent_level ( )
static

Gets the indent level.

Returns
The indent level. The default is zero.
Remarks
The xtd::diagnostics::debug::indent_level property represents the number of times the indent of size xtd::diagnostics::debug::indent_size is applied. This property is stored on per-thread/per-request basis.

◆ indent_level() [2/2]

static void xtd::diagnostics::debug::indent_level ( uint32_t  indent_level)
static

Sets the indent level.

Parameters
indent_levelThe indent level. The default is zero.
Remarks
The xtd::diagnostics::debug::indent_level property represents the number of times the indent of size xtd::diagnostics::debug::indent_size is applied. This property is stored on per-thread/per-request basis.

◆ indent_size() [1/2]

static uint32_t xtd::diagnostics::debug::indent_size ( )
static

Gets the number of spaces in an indent.

Returns
The number of spaces in an indent. The default is four.
Remarks
A xtd::diagnostics::ostream_trace_listener interprets this number as spaces. An xtd::diagnostics::event_log_trace_listener ignores this value.

◆ indent_size() [2/2]

static void xtd::diagnostics::debug::indent_size ( uint32_t  indent_size)
static

Sets the number of spaces in an indent.

Parameters
indent_sizeThe number of spaces in an indent. The default is four.
Remarks
A xtd::diagnostics::ostream_trace_listener interprets this number as spaces. An xtd::diagnostics::event_log_trace_listener ignores this value.

◆ listeners() [1/2]

static listener_collection& xtd::diagnostics::debug::listeners ( )
static

Gets the collection of listeners that is monitoring the trace output.

Returns
A xtd::diagnostics::debug::listener_collection that represents a collection of type xtd::diagnostics::trace_listener monitoring the trace output.
Remarks
The xtd::diagnostics::debug::listeners produce formatted output from the trace output. By default, the collection contains an instance of the xtd::diagnostics::default_trace_listener class. If you want to remove the default listener, call the erase method, and pass it the instance of the xtd::diagnostics::default_trace_listener. To redirect output to the console window, add an instance of the xtd::diagnostics::console_trace_listener class.
Note
The xtd::diagnostics::debug::listeners collection is shared by both the xtd::diagnostics::debug and the xtd::diagnostics::trace classes; adding a trace listener to either class adds the listener to both.

◆ listeners() [2/2]

static void xtd::diagnostics::debug::listeners ( const listener_collection listeners)
static

Sets the collection of listeners that is monitoring the trace output. @paral$m listeners A xtd::diagnostics::debug::listener_collection that represents a collection of type xtd::diagnostics::trace_listener monitoring the trace output.

Remarks
The xtd::diagnostics::debug::listeners produce formatted output from the trace output. By default, the collection contains an instance of the xtd::diagnostics::default_trace_listener class. If you want to remove the default listener, call the erase method, and pass it the instance of the xtd::diagnostics::default_trace_listener. To redirect output to the console window, add an instance of the xtd::diagnostics::console_trace_listener class.
Note
The xtd::diagnostics::debug::listeners collection is shared by both the xtd::diagnostics::debug and the xtd::diagnostics::trace classes; adding a trace listener to either class adds the listener to both.

◆ print() [1/2]

template<typename ... args_t>
static void xtd::diagnostics::debug::print ( const xtd::ustring format,
args_t &&...  args 
)
inlinestatic

Writes a formatted string followed by a line terminator to the trace listeners in the listeners collection.

Parameters
formatA composite format string that contains text intermixed with zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Exceptions
xtd::format_exceptionformat is invalid. -or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format.

◆ print() [2/2]

static void xtd::diagnostics::debug::print ( const xtd::ustring message)
inlinestatic

Writes a message followed by a line terminator to the trace listeners in the listeners collection.

Parameters
messageThe message to write.
Remarks
The default line terminator is a carriage return followed by a line feed. By default, the output is written to an instance of default_trace_listener.

◆ show_assert_dialog() [1/2]

static bool xtd::diagnostics::debug::show_assert_dialog ( )
static

Gets a value indicating whether the assert dialog should be show.

Returns
true if assert dialog is to be shown; otherwise, false. The default is true.
Remarks
The show assert dialog is used when xtd::diagnostics::debug::cassert or td::diagnostics::trace::cassert or assert_ is called to ask user to ignore, continue or retry the assert.
Note
The xtd::diagnostics::debug::show_assert_dialog boolean is shared by both the xtd::diagnostics::debug and the xtd::diagnostics::trace classes; updating the boolean to either class modify the show assert dialog to both.

◆ show_assert_dialog() [2/2]

static void xtd::diagnostics::debug::show_assert_dialog ( bool  show_assert_dialog)
static

Sets a value indicating whether the assert dialog should be show.

Parameters
show_assert_dialogtrue if assert dialog is to be shown; otherwise, false. The default is true.
Remarks
The show assert dialog is used when xtd::diagnostics::debug::cassert or td::diagnostics::trace::cassert or assert_ is called to ask user to ignore, continue or retry the assert.
Note
The xtd::diagnostics::debug::show_assert_dialog boolean is shared by both the xtd::diagnostics::debug and the xtd::diagnostics::trace classes; updating the boolean to either class modify the show assert dialog to both.

◆ trace_error() [1/2]

static void xtd::diagnostics::debug::trace_error ( const xtd::ustring message)
inlinestatic

Writes an error message to the trace listeners in the Listeners collection using the specified message.

Parameters
messageThe informative message to write.
Remarks
trace_error calls the trace_event method for each trace listener, with the trace event type error, passing the informative message as the message string.

◆ trace_error() [2/2]

template<typename ... objects_t>
static void xtd::diagnostics::debug::trace_error ( const xtd::ustring message,
const objects_t &...  args 
)
inlinestatic

Writes an error message to the trace listeners in the listeners collection using the specified array of objects and formatting information.

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Remarks
trace_error calls the trace_event methods in the trace listeners with the trace event type error, passing the message content as an object array with formatting information.

◆ trace_information() [1/2]

static void xtd::diagnostics::debug::trace_information ( const xtd::ustring message)
inlinestatic

Writes an informational message to the trace listeners in the listeners collection using the specified message.

Parameters
messageThe informative message to write.
Remarks
trace_information calls the trace_event method for each trace listener, with the trace event type information, passing the informative message as the message string.

◆ trace_information() [2/2]

template<typename ... objects_t>
static void xtd::diagnostics::debug::trace_information ( const xtd::ustring message,
const objects_t &...  args 
)
inlinestatic

Writes an informational message to the trace listeners in the listeners collection using the specified array of objects and formatting information.

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Remarks
trace_information calls the trace_event methods in the trace listeners with the trace event type information, passing the message content as an object array with formatting information.

◆ trace_warning() [1/2]

static void xtd::diagnostics::debug::trace_warning ( const xtd::ustring message)
inlinestatic

Writes a warning message to the trace listeners in the listeners collection using the specified message.

Parameters
messageThe informative message to write.
Remarks
trace_warning calls the trace_event method for each trace listener with the trace event type Warning, passing the informative message as the message string.

◆ trace_warning() [2/2]

template<typename ... objects_t>
static void xtd::diagnostics::debug::trace_warning ( const xtd::ustring message,
const objects_t &...  args 
)
inlinestatic

Writes a warning message to the trace listeners in the listeners collection using the specified array of objects and formatting information.

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Remarks
trace_warning calls the trace_event methods in the trace listeners with the trace event type Warning, passing the message content as an object array with formatting information.

◆ unindent()

static void xtd::diagnostics::debug::unindent ( )
static

Decreases the current indent_level by one.

◆ use_global_lock() [1/2]

static bool xtd::diagnostics::debug::use_global_lock ( )
static

Gets a value indicating whether the global lock should be used.

Returns
true if the global lock is to be used; otherwise, false. The default is true.
Remarks
The global lock is always used if the trace listener is not thread safe, regardless of the value of xtd::diagnostics::debug::use_global_lock. The IsThreadSafe property is used to determine if the listener is thread safe. The global lock is not used only if the value of UseGlobalLock is false and the value of IsThreadSafe is true. The default behavior is to use the global lock.

◆ use_global_lock() [2/2]

static void xtd::diagnostics::debug::use_global_lock ( bool  use_global_lock)
static

Sets a value indicating whether the global lock should be used.

Parameters
use_global_locktrue if the global lock is to be used; otherwise, false. The default is true.
Remarks
The global lock is always used if the trace listener is not thread safe, regardless of the value of UseGlobalLock. The xtd::diagnostics::debug::is_thread_safe property is used to determine if the listener is thread safe. The global lock is not used only if the value of xtd::diagnostics::debug::use_global_lock is false and the value of xtd::diagnostics::debug::is_thread_safe is true. The default behavior is to use the global lock.

◆ write() [1/4]

template<typename object_t >
static void xtd::diagnostics::debug::write ( const object_t &  message)
inlinestatic

Writes a message to the trace listeners in the listeners collection.

Parameters
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write() [2/4]

template<typename object_t >
static void xtd::diagnostics::debug::write ( const object_t &  message,
const xtd::ustring category 
)
inlinestatic

Writes a category name and message to the trace listeners in the listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.
Remarks
By default, the output is written to an instance of default_trace_listener.
Use the category parameter to group output messages.
This method calls the write method of the trace listener.

◆ write() [3/4]

template<typename ... args_t>
static void xtd::diagnostics::debug::write ( const xtd::ustring format,
args_t &&...  args 
)
inlinestatic

Writes a formatted string to the trace listeners in the listeners collection.

Parameters
formatA composite format string that contains text intermixed with zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write() [4/4]

static void xtd::diagnostics::debug::write ( const xtd::ustring message)
inlinestatic

Writes a message to the trace listeners in the listeners collection.

Parameters
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_if() [1/3]

template<typename object_t >
static void xtd::diagnostics::debug::write_if ( bool  condition,
const object_t &  message 
)
inlinestatic

Writes a message to the trace listeners in the Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_if() [2/3]

template<typename object_t >
static void xtd::diagnostics::debug::write_if ( bool  condition,
const object_t &  message,
const xtd::ustring category 
)
inlinestatic

Writes a category name and message to the trace listeners in the Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
categoryA category name used to organize the output.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_if() [3/3]

static void xtd::diagnostics::debug::write_if ( bool  condition,
const xtd::ustring message 
)
inlinestatic

Writes a message to the trace listeners in the Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_line() [1/5]

static void xtd::diagnostics::debug::write_line ( )
inlinestatic

Writes a line terminator to the trace listeners in the listeners collection.

Parameters
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.
Examples
debug_form.cpp.

◆ write_line() [2/5]

template<typename object_t >
static void xtd::diagnostics::debug::write_line ( const object_t &  message)
inlinestatic

Writes a message followed by a line terminator to the trace listeners in the listeners collection.

Parameters
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_line() [3/5]

template<typename object_t >
static void xtd::diagnostics::debug::write_line ( const object_t &  message,
const xtd::ustring category 
)
inlinestatic

Writes a category name and message followed by a line terminator to the trace listeners in the listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.
Remarks
By default, the output is written to an instance of default_trace_listener.
Use the category parameter to group output messages.
This method calls the write method of the trace listener.

◆ write_line() [4/5]

template<typename ... args_t>
static void xtd::diagnostics::debug::write_line ( const xtd::ustring format,
args_t &&...  args 
)
inlinestatic

Writes a formatted string followed by a line terminator to the trace listeners in the listeners collection.

Parameters
formatA composite format string that contains text intermixed with zero or more format items, which correspond to objects in the args array.
...argsAn object array containing zero or more objects to format.
Exceptions
xtd::format_exceptionformat is invalid. -or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format.

◆ write_line() [5/5]

static void xtd::diagnostics::debug::write_line ( const xtd::ustring message)
inlinestatic

Writes a message followed by a line terminator to the trace listeners in the listeners collection.

Parameters
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_line_if() [1/3]

template<typename object_t >
static void xtd::diagnostics::debug::write_line_if ( bool  condition,
const object_t &  message 
)
inlinestatic

Writes a message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_line_if() [2/3]

template<typename object_t >
static void xtd::diagnostics::debug::write_line_if ( bool  condition,
const object_t &  message,
const xtd::ustring category 
)
inlinestatic

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
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
categoryA category name used to organize the output.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

◆ write_line_if() [3/3]

static void xtd::diagnostics::debug::write_line_if ( bool  condition,
const xtd::ustring message 
)
inlinestatic

Writes a message followed by a line terminator to the trace listeners in the Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
Remarks
By default, the output is written to an instance of default_trace_listener.
This method calls the write method of the trace listener.

The documentation for this class was generated from the following file: