xtd 0.2.0
Loading...
Searching...
No Matches
xtd::diagnostics::trace Class Reference
Inheritance diagram for xtd::diagnostics::trace:
xtd::static_object

Definition

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

Provides a set of methods and properties that help you debug the execution of your code....
Definition trace.hpp:40
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
#define core_export_
Define shared library export.
Definition core_export.hpp:13
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 xtd;
using namespace xtd::diagnostics;
auto main() -> int {
trace::listeners().push_back(new_ptr<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
static std::ostream out
Gets the standard output stream. A std::basic_ostream<char_t> that represents the standard output str...
Definition console.hpp:52
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static void write_line()
Writes a line terminator to the trace listeners in the listeners collection.
Definition trace.hpp:343
static bool auto_flush() noexcept
Gets whether Flush should be called on the Listeners after every write.
static listener_collection & listeners() noexcept
Gets the collection of listeners that is monitoring the trace output.
static void unindent() noexcept
Decreases the current indent_level by one.
static void indent() noexcept
Increases the current indent_level by one.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10

Public Aliases

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

Public Static Properties

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

Public Static Methods

static void cassert (bool condition, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 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::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 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::string &message, const xtd::string &detail_message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Checks for a condition; if the condition is false, displays a message box that shows the call stack.
 
static void fail (const xtd::string &message)
 Emits the specified error message.
 
static void fail (const xtd::string &message, const xtd::string &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 () noexcept
 Increases the current indent_level by one.
 
static void print (const xtd::string &message)
 Writes a message followed by a line terminator to the trace listeners in the listeners collection.
 
template<typename ... args_t>
static void print (const xtd::string &format, args_t &&... args)
 Writes a formatted string followed by a line terminator to the trace listeners in the listeners collection.
 
static void trace_error (const xtd::string &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::string &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::string &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::string &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::string &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::string &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 () noexcept
 Decreases the current indent_level by one.
 
static void write (const xtd::string &message)
 Writes a message to the trace listeners in the listeners collection.
 
template<typename object_t >
static void write (const object_t &message)
 Writes a message to the trace listeners in the listeners collection.
 
template<typename object_t >
static void write (const object_t &message, const xtd::string &category)
 Writes a category name and message to the trace listeners in the listeners collection.
 
template<typename ... args_t>
static void write (const xtd::string &format, args_t &&... args)
 Writes a formatted string to the trace listeners in the listeners collection.
 
static void write_if (bool condition, const xtd::string &message)
 Writes a message to the trace listeners in the Listeners collection if a condition is true.
 
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.
 
template<typename object_t >
static void write_if (bool condition, const object_t &message, const xtd::string &category)
 Writes a category name and 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.
 
static void write_line (const xtd::string &message)
 Writes a message followed by a line terminator to the trace listeners in the listeners collection.
 
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.
 
template<typename object_t >
static void write_line (const object_t &message, const xtd::string &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::string &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_if (bool condition, const xtd::string &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_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.
 
template<typename object_t >
static void write_line_if (bool condition, const object_t &message, const xtd::string &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.
 

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.

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

◆ 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 xtd::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.
Deprecated:
Replaced by xtd::diagnostics::default_trace_listener::assert_ui_enabled - Will be removed in version 0.4.0.

◆ 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 xtd::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.
Deprecated:
Replaced by xtd::diagnostics::default_trace_listener::assert_ui_enabled - Will be removed in version 0.4.0.

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

◆ cassert() [1/3]

static void xtd::diagnostics::trace::cassert ( bool  condition,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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 (optional) stack frame corresponding to the generated assert.

◆ cassert() [2/3]

static void xtd::diagnostics::trace::cassert ( bool  condition,
const xtd::string message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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 (optional) stack frame corresponding to the generated assert.

◆ cassert() [3/3]

static void xtd::diagnostics::trace::cassert ( bool  condition,
const xtd::string message,
const xtd::string detail_message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
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 (optional) stack frame corresponding to the generated assert.

◆ fail() [1/2]

static void xtd::diagnostics::trace::fail ( const xtd::string 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::string message,
const xtd::string 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.

◆ print() [1/2]

static void xtd::diagnostics::trace::print ( const xtd::string 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::string 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.

◆ trace_error() [1/2]

static void xtd::diagnostics::trace::trace_error ( const xtd::string 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::string 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::string 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::string 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::string 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::string 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.

◆ write() [1/4]

static void xtd::diagnostics::trace::write ( const xtd::string 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::string 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::string 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::string 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::string 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
mouse_events.cpp.

◆ write_line() [2/5]

static void xtd::diagnostics::trace::write_line ( const xtd::string 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::string 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::string 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::string 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::string 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: