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

#include <trace.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 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.

Inherits xtd::static_object.

Public Types

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

Static Public Member Functions

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

Member Typedef Documentation

◆ listener_collection

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

Member Function Documentation

◆ auto_flush() [1/2]

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

Get 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)
static

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/4]

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/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");
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
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
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::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.

◆ cassert() [3/4]

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() [4/4]

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.

◆ 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 ( )
static

Increases the current indent_level by one.

◆ indent_level() [1/2]

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

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_t  indent_level)
static

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_t xtd::diagnostics::trace::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 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_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 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 ( )
static

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)
static

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]

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.

◆ print() [2/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.

◆ show_assert_dialog() [1/2]

static bool xtd::diagnostics::trace::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::trace::show_assert_dialog ( bool  show_assert_dialog)
static

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 ( )
static

Decreases the current indent_level by one.

◆ use_global_lock() [1/2]

static bool xtd::diagnostics::trace::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 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)
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 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]

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

template<typename object >
static void xtd::diagnostics::trace::write_if ( bool  condition,
const object 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 >
static void xtd::diagnostics::trace::write_if ( bool  condition,
const object 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::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_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
trace_form.cpp.

◆ write_line() [2/5]

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

template<typename object >
static void xtd::diagnostics::trace::write_line_if ( bool  condition,
const object 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 >
static void xtd::diagnostics::trace::write_line_if ( bool  condition,
const object 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::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.

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