OpenTAP 9.25
API Reference
Static Public Member Functions | Properties | List of all members
OpenTap.Log Class Reference

This class extends System.Diagnostics.Log to provide shorthand methods for logging/tracing messages at different levels. More...

Static Public Member Functions

static void AddListener (ILogListener listener)
 Makes a TraceListener start receiving log messages. More...
 
static void RemoveListener (ILogListener listener)
 Stops a specified TraceListener from receiving log messages. More...
 
static ReadOnlyCollection< ILogListenerGetListeners ()
 Gets all added TraceListeners. More...
 
static TraceSource CreateSource (string name)
 Creates a new log source. More...
 
static TraceSource CreateSource (string name, object owner)
 Creates a new owned log source. Note that any given object can only have one owned TraceSource. More...
 
static TraceSource GetOwnedSource (object owner)
 Gets the source of a specified owner. More...
 
static void RemoveSource (TraceSource source)
 Removes a previously Created Log from the list of sources. More...
 
static void TraceInformation (this TraceSource trace, string message)
 Trace a message at level "Information" (LogEventType.Information). More...
 
static void Debug (this TraceSource trace, string message, params object[] args)
 Trace a message at level "Debug" (LogEventType.Debug). More...
 
static void Info (this TraceSource trace, Stopwatch timer, string message, params object[] args)
 Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Information level log message. More...
 
static void Debug (this TraceSource trace, Stopwatch timer, string message, params object[] args)
 Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Debug level end message. More...
 
static void Warning (this TraceSource trace, Stopwatch timer, string message, params object[] args)
 Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Warning level end message. More...
 
static void Error (this TraceSource trace, Stopwatch timer, string message, params object[] args)
 Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Error level end message. More...
 
static void Info (this TraceSource trace, TimeSpan elapsed, string message, params object[] args)
 Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Information level log message. More...
 
static void Debug (this TraceSource trace, TimeSpan elapsed, string message, params object[] args)
 Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Debug level end message. More...
 
static void Warning (this TraceSource trace, TimeSpan elapsed, string message, params object[] args)
 Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Warning level end message. More...
 
static void Error (this TraceSource trace, TimeSpan elapsed, string message, params object[] args)
 Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Error level end message. More...
 
static void Info (this TraceSource trace, string message, params object[] args)
 Trace a message at level "Information" (LogEventType.Information). More...
 
static void Warning (this TraceSource trace, string message, params object[] args)
 Trace a message at level "Warning" (LogEventType.Warning). More...
 
static void Error (this TraceSource trace, string message, params object[] args)
 Trace a message at level "Error" (LogEventType.Error). More...
 
static void Debug (this TraceSource trace, Exception exception)
 Write exception details (including stack trace) to the trace at level "Debug" (LogEventType.Error). More...
 
static void Error (this TraceSource trace, Exception exception)
 Write exception details (including stack trace) to the trace at level "Error" (LogEventType.Error). More...
 
static void Flush ()
 Flushes all waiting log trace events.
 
static void StartSync ()
 Puts the current log context into synchronous mode. All TraceSources will now wait for their trace events to be handled by all TraceListeners before returning.
 
static void StopSync ()
 Ends synchronous mode. Must be called after .
 

Properties

static ILogContext Context [get]
 The current log context.
 

Detailed Description

This class extends System.Diagnostics.Log to provide shorthand methods for logging/tracing messages at different levels.

Member Function Documentation

◆ AddListener()

static void OpenTap.Log.AddListener ( ILogListener  listener)
inlinestatic

Makes a TraceListener start receiving log messages.

Parameters
listenerThe TraceListener to add.

◆ CreateSource() [1/2]

static TraceSource OpenTap.Log.CreateSource ( string  name)
inlinestatic

Creates a new log source.

Parameters
nameThe name of the Log.
Returns
The created Log.

◆ CreateSource() [2/2]

static TraceSource OpenTap.Log.CreateSource ( string  name,
object  owner 
)
inlinestatic

Creates a new owned log source. Note that any given object can only have one owned TraceSource.

Parameters
nameThe name of the Log.
ownerThe object owning the log. This is used to enable OpenTAP to emit log messages on behalf of the owner object.
Returns
The created Log.

◆ Debug() [1/4]

static void OpenTap.Log.Debug ( this TraceSource  trace,
Exception  exception 
)
inlinestatic

Write exception details (including stack trace) to the trace at level "Debug" (LogEventType.Error).

Parameters
tracethis(extension method).
exceptionInputs error exception.

◆ Debug() [2/4]

static void OpenTap.Log.Debug ( this TraceSource  trace,
Stopwatch  timer,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Debug level end message.

Parameters
trace
timer
message
args

◆ Debug() [3/4]

static void OpenTap.Log.Debug ( this TraceSource  trace,
string  message,
params object[]  args 
)
inlinestatic

Trace a message at level "Debug" (LogEventType.Debug).

Parameters
tracethis(extension method).
messageMessage to write.
argsparameters (see String.Format(string, object)).

◆ Debug() [4/4]

static void OpenTap.Log.Debug ( this TraceSource  trace,
TimeSpan  elapsed,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Debug level end message.

Parameters
trace
elapsed
message
args

◆ Error() [1/4]

static void OpenTap.Log.Error ( this TraceSource  trace,
Exception  exception 
)
inlinestatic

Write exception details (including stack trace) to the trace at level "Error" (LogEventType.Error).

Parameters
tracethis(extension method).
exceptionInputs error exception.

◆ Error() [2/4]

static void OpenTap.Log.Error ( this TraceSource  trace,
Stopwatch  timer,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Error level end message.

Parameters
trace
timer
message
args

◆ Error() [3/4]

static void OpenTap.Log.Error ( this TraceSource  trace,
string  message,
params object[]  args 
)
inlinestatic

Trace a message at level "Error" (LogEventType.Error).

Parameters
tracethis(extension method).
messageMessage to write.
argsparameters (see String.Format(string, object)).

◆ Error() [4/4]

static void OpenTap.Log.Error ( this TraceSource  trace,
TimeSpan  elapsed,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Error level end message.

Parameters
trace
elapsed
message
args

◆ GetListeners()

static ReadOnlyCollection< ILogListener > OpenTap.Log.GetListeners ( )
inlinestatic

Gets all added TraceListeners.

Returns
A readonly collection of TraceListeners.

◆ GetOwnedSource()

static TraceSource OpenTap.Log.GetOwnedSource ( object  owner)
inlinestatic

Gets the source of a specified owner.

Parameters
owner
Returns
returns the TraceSource or null if the owner owns no source.

◆ Info() [1/3]

static void OpenTap.Log.Info ( this TraceSource  trace,
Stopwatch  timer,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Information level log message.

Parameters
trace
timer
message
args

◆ Info() [2/3]

static void OpenTap.Log.Info ( this TraceSource  trace,
string  message,
params object[]  args 
)
inlinestatic

Trace a message at level "Information" (LogEventType.Information).

Parameters
tracethis(extension method).
messageMessage to write.
argsparameters (see String.Format(string, object)).

◆ Info() [3/3]

static void OpenTap.Log.Info ( this TraceSource  trace,
TimeSpan  elapsed,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Information level log message.

Parameters
trace
elapsed
message
args

◆ RemoveListener()

static void OpenTap.Log.RemoveListener ( ILogListener  listener)
inlinestatic

Stops a specified TraceListener from receiving log messages.

Parameters
listenerThe TraceListener to remove.

◆ RemoveSource()

static void OpenTap.Log.RemoveSource ( TraceSource  source)
inlinestatic

Removes a previously Created Log from the list of sources.

Parameters
source

◆ TraceInformation()

static void OpenTap.Log.TraceInformation ( this TraceSource  trace,
string  message 
)
inlinestatic

Trace a message at level "Information" (LogEventType.Information).

Parameters
tracethis(extension method).
messageMessage to write.

◆ Warning() [1/3]

static void OpenTap.Log.Warning ( this TraceSource  trace,
Stopwatch  timer,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time measured by timer appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Warning level end message.

Parameters
trace
timer
message
args

◆ Warning() [2/3]

static void OpenTap.Log.Warning ( this TraceSource  trace,
string  message,
params object[]  args 
)
inlinestatic

Trace a message at level "Warning" (LogEventType.Warning).

Parameters
tracethis(extension method).
messageMessage to write.
argsparameters (see String.Format(string, object)).

◆ Warning() [3/3]

static void OpenTap.Log.Warning ( this TraceSource  trace,
TimeSpan  elapsed,
string  message,
params object[]  args 
)
inlinestatic

Writes a message with the time appended in the format [xx.x (m/u/n)s]. if timer is a TimerToken it will be disposed. Warning level end message.

Parameters
trace
elapsed
message
args

OpenTAP 9.25 API built Tue Aug 6 2024 07:49:24