xtd 0.2.0
xtd::diagnostics::trace Class Reference

Definition

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

class core_export_ trace static_
Inheritance
xtd::static_objectxtd::diagnostics::trace
Header
#include <xtd/diagnostics/trace>
Namespace
xtd::diagnostics
Library
xtd.core
Remarks
You can use the properties and methods in the 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: write, write_line, write_if, and write_line_if.
The boolean_switch and 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 switch class and the trace_switches topic.
You can customize the tracing output's target by adding trace_listener instances to or removing instances from the listeners collection. The listeners collection is shared by both the debug and the trace classes; adding a trace listener to either class adds the listener to both. By default, trace output is emitted using the default_trace_listener class.
Note
Adding a trace listener to the 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
The debug class provides properties to get or set the level of indent, the indent_size, and whether to auto_flush after each write.
You must enable debug or trace 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 enable trace mode with cmake, add the add_definitions(-DTRACE) command line in the CMakeLists.txt of your project, or you can add #define TRACE 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.
To activate your code if TRACE is defined, you must enclose calls to the methods of Debug in an #if defined(TRACE) ... #endif block, and add the /DTRACE option to the compiler command line or add #define TRACE 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.
// Specify -DTRACE when compiling or add #define TRACE in the source file.
#define DEBUG
#include <xtd/diagnostics/trace>
#include <xtd/diagnostics/ostream_trace_listener>
#include <xtd/console>
using namespace std;
using namespace xtd;
using namespace xtd::diagnostics;
auto main()->int {
trace::listeners().push_back(make_shared<ostream_trace_listener>(console::out));
trace::write_line("Entering Main");
console::write_line("Hello World.");
trace::write_line("Exiting Main");
}
// This code produces the following output :
//
// Entering Main
// Hello World.
// Exiting Main

Alias

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

Properties

static bool auto_flush () noexcept
 Gets whether Flush should be called on the Listeners after every write. More...
 
static void auto_flush (bool auto_flush) noexcept
 Sets whether Flush should be called on the Listeners after every write. More...
 
static uint32 indent_level () noexcept
 Gets the indent level. More...
 
static void indent_level (uint32 indent_level) noexcept
 Sets the indent level. More...
 
static uint32 indent_size () noexcept
 Gets the number of spaces in an indent. More...
 
static void indent_size (uint32 indent_size) noexcept
 Sets the number of spaces in an indent. More...
 
static listener_collectionlisteners () noexcept
 Gets the collection of listeners that is monitoring the trace output. More...
 
static void listeners (const listener_collection &listeners) noexcept
 Sets the collection of listeners that is monitoring the trace output. More...
 
static bool show_assert_dialog () noexcept
 Gets a value indicating whether the assert dialog should be show. More...
 
static void show_assert_dialog (bool show_assert_dialog) noexcept
 Sets a value indicating whether the assert dialog should be show. More...
 
static bool use_global_lock () noexcept
 Gets a value indicating whether the global lock should be used. More...
 
static void use_global_lock (bool use_global_lock) noexcept
 Sets a value indicating whether the global lock should be used. More...
 

Methods

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::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 cassert (bool condition, const xtd::ustring &message, const xtd::ustring &detail_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::ustring &detail_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 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 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 () noexcept
 Increases the current indent_level by one. 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...
 
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 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>
static void trace_error (const xtd::ustring &message, const objects &... 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>
static void trace_information (const xtd::ustring &message, const objects &... 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>
static void trace_warning (const xtd::ustring &message, const objects &... 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 () noexcept
 Decreases the current indent_level by one. 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 (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_if (bool condition, const xtd::ustring &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)
 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_line ()
 Writes 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 (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_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...
 
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...
 

Member Typedef Documentation

◆ listener_collection

Member Function Documentation

◆ auto_flush() [1/2]

static bool xtd::diagnostics::trace::auto_flush ( )
staticnoexcept

Gets whether Flush should be called on the Listeners after every write.

Returns
true if Flush is called on the Listeners after every write; otherwise, false.
Remarks
The default is false.
Flushing the stream will not flush its underlying encoder unless you explicitly call Flush or Close. Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

◆ auto_flush() [2/2]

static void xtd::diagnostics::trace::auto_flush ( bool  auto_flush)
staticnoexcept

Sets whether Flush should be called on the Listeners after every write.

Parameters
auto_flushtrue if Flush is called on the Listeners after every write; otherwise, false.
Remarks
The default is false.
Flushing the stream will not flush its underlying encoder unless you explicitly call Flush or Close. Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

◆ cassert() [1/6]

static void xtd::diagnostics::trace::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::trace::cassert_ method.
#define TRACE
#include <xtd/diagnostics/trace>
#include <xtd/console>
using namespace xtd;
using namespace xtd::diagnostics;
auto main()->int {
// Uncomment following line to remove assert dialog
//diagnostics::debug::show_assert_dialog(false);
auto index = 0;
console::write_line("Start application");
trace::cassert_(index > 0, "index must be greater than 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 tace_cassert.cpp line 13.
// > If user choose continue running after break.
// End application
//
// > If user clicks assert dialog 'Ignore' button:
// Start application
// End application

◆ cassert() [2/6]

static void xtd::diagnostics::trace::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 Listeners collection.

◆ cassert() [3/6]

static void xtd::diagnostics::trace::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.

◆ cassert() [4/6]

static void xtd::diagnostics::trace::cassert ( bool  condition,
const xtd::ustring message,
const xtd::ustring detail_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.
detail_messageThe detailed message to send to the xtd::diagnostics::debug::listeners collection.

◆ cassert() [5/6]

static void xtd::diagnostics::trace::cassert ( bool  condition,
const xtd::ustring message,
const xtd::ustring detail_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.
detail_messageThe detailed message to send to the xtd::diagnostics::debug::listeners collection.
stack_frameThe stack frame corresponding to the generated assert.

◆ cassert() [6/6]

static void xtd::diagnostics::trace::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.

◆ fail() [1/2]

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

Emits the specified error message.

Parameters
messageA 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()).

◆ fail() [2/2]

static void xtd::diagnostics::trace::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::trace::flush ( )
inlinestatic

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

◆ indent()

static void xtd::diagnostics::trace::indent ( )
staticnoexcept

Increases the current indent_level by one.

◆ indent_level() [1/2]

static uint32 xtd::diagnostics::trace::indent_level ( )
staticnoexcept

Gets the indent level.

Returns
The indent level. The default is zero.
Remarks
The IndentLevel property represents the number of times the indent of size IndentSize is applied. This property is stored on per-thread/per-request basis.

◆ indent_level() [2/2]

static void xtd::diagnostics::trace::indent_level ( uint32  indent_level)
staticnoexcept

Sets the indent level.

Parameters
indent_levelThe indent level. The default is zero.
Remarks
The IndentLevel property represents the number of times the indent of size IndentSize is applied. This property is stored on per-thread/per-request basis.

◆ indent_size() [1/2]

static uint32 xtd::diagnostics::trace::indent_size ( )
staticnoexcept

Gets the number of spaces in an indent.

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

◆ indent_size() [2/2]

static void xtd::diagnostics::trace::indent_size ( uint32  indent_size)
staticnoexcept

Sets the number of spaces in an indent.

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

◆ listeners() [1/2]

static listener_collection& xtd::diagnostics::trace::listeners ( )
staticnoexcept

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

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

◆ listeners() [2/2]

static void xtd::diagnostics::trace::listeners ( const listener_collection listeners)
staticnoexcept

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

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

◆ print() [1/2]

static void xtd::diagnostics::trace::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.

◆ print() [2/2]

template<typename ... args_t>
static void xtd::diagnostics::trace::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.

◆ show_assert_dialog() [1/2]

static bool xtd::diagnostics::trace::show_assert_dialog ( )
staticnoexcept

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::trace::show_assert_dialog ( bool  show_assert_dialog)
staticnoexcept

Sets 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.

◆ trace_error() [1/2]

static void xtd::diagnostics::trace::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>
static void xtd::diagnostics::trace::trace_error ( const xtd::ustring message,
const objects &...  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::trace::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>
static void xtd::diagnostics::trace::trace_information ( const xtd::ustring message,
const objects &...  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::trace::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>
static void xtd::diagnostics::trace::trace_warning ( const xtd::ustring message,
const objects &...  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::trace::unindent ( )
staticnoexcept

Decreases the current indent_level by one.

◆ use_global_lock() [1/2]

static bool xtd::diagnostics::trace::use_global_lock ( )
staticnoexcept

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 UseGlobalLock. 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::trace::use_global_lock ( bool  use_global_lock)
staticnoexcept

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 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.

◆ write() [1/4]

static void xtd::diagnostics::trace::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() [2/4]

template<typename object_t >
static void xtd::diagnostics::trace::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() [3/4]

template<typename object_t >
static void xtd::diagnostics::trace::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() [4/4]

template<typename ... args_t>
static void xtd::diagnostics::trace::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_if() [1/3]

static void xtd::diagnostics::trace::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_if() [2/3]

template<typename object_t >
static void xtd::diagnostics::trace::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() [3/3]

template<typename object_t >
static void xtd::diagnostics::trace::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_line() [1/5]

static void xtd::diagnostics::trace::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:
application_application_exit.cpp, application_events.cpp, hello_world_diagnostics.cpp, mouse_events.cpp, and trace_form.cpp.

◆ write_line() [2/5]

static void xtd::diagnostics::trace::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() [3/5]

template<typename object_t >
static void xtd::diagnostics::trace::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() [4/5]

template<typename object_t >
static void xtd::diagnostics::trace::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() [5/5]

template<typename ... args_t>
static void xtd::diagnostics::trace::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_if() [1/3]

static void xtd::diagnostics::trace::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.

◆ write_line_if() [2/3]

template<typename object_t >
static void xtd::diagnostics::trace::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() [3/3]

template<typename object_t >
static void xtd::diagnostics::trace::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.

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