Configuration example: The following XDC configuration statements
create a logger instance, assign it as the default logger for all
modules, and enable
USER1 logging in all modules of the package
my.pkg. See the
Diags.setMaskMeta() function
for details on specifying the module names.
var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var LoggerUart = xdc.useModule('xdc.runtime.LoggerUart');
var LoggerUartParams = new LoggerUart.Params();
Defaults.common$.logger = LoggerUart.create(LoggerUartParams);
Diags.setMaskMeta("my.pkg.%", Diags.USER1, Diags.RUNTIME_ON);
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool LoggerUart_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool LoggerUart_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 LoggerUart_Module_getMask();
// Returns the diagnostics mask for this module
Void LoggerUart_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
|
typedef struct LoggerUart_Object LoggerUart_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct LoggerUart_Struct LoggerUart_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
|
typedef struct LoggerUart_Params {
// Instance config-params structure
// Common per-instance configs
} LoggerUart_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
Instance Creation |
|
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
DETAILS
The logger instance will route all log events it receives to
the
System.printf function.
Instance Deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
LoggerUart_disable() // instance |
|
Disable a log
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
DETAILS
Events written to a disabled log are silently discarded.
RETURNS
The function returns the state of the log (TRUE if enabled,
FALSE if disabled) before the call. This return value allows
clients to restore the previous state.
Note: not thread safe.
LoggerUart_enable() // instance |
|
Enable a log
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
RETURNS
The function returns the state of the log (TRUE if enabled,
FALSE if disabled) before the call. This return value allows
clients to restore the previous state.
Note: not thread safe.
LoggerUart_write0() // instance |
|
Process a log event with 0 arguments
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
DETAILS
Same as write4 except with 0 arguments rather than 4.
SEE
LoggerUart_write1() // instance |
|
Process a log event with 1 arguments
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
DETAILS
Same as write4 except with 1 arguments rather than 4.
SEE
LoggerUart_write2() // instance |
|
Process a log event with 2 arguments
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
DETAILS
Same as write4 except with 2 arguments rather than 4.
SEE
LoggerUart_write4() // instance |
|
Process a log event with up to 4 arguments
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
evt
event to be logged
mid
module ID of the module which logged the event
a1
arbitrary argument passed by caller
DETAILS
The
evt argument is of type Log.Event, which encodes the
Log.EventId, the
Diags.Mask, and the
Diags.EventLevel of the event. The event ID can be obtained
via
Types.getEventId(evt), the Diags mask can be obtained via
Diags.getMask(evt), and the event level can be obtained via
Diags.getLevel(evt).
The modId argument is the module ID of the module that logged the
event.
The event information can be used by the logger to handle different
events specially. For example, the event ID can be used to compare
against other known Log.Events.
if (Log_getEventId(MY_EVENT) == Log_getEventId(evt)) {
:
}
The Diags mask and event level can be used for filtering of events
based on event level (see
IFilterLogger), or even routing
events to separate loggers based on diags category (see, for example,
LoggerBuf.statusLogger).
The Diags mask and event level are useful for handling the event, but
are generally not recorded by the logger because they are not needed in
decoding and displaying the event. A more suitable value to record is a
Types.Event, which encodes the event ID and module ID. For
example, the
Log.EventRec type stores a
Types.Event
in its record definition. A
Types.Event can be created using
the
Types.makeEvent API given the event ID and module ID.
The event ID value of
0 is used to indicate an event triggered by a
call to one of the
Log_print[0-6] methods. These
methods take a format string rather than a
Log_Event argument and,
as a result, the event ID encoded in
evt is
0 and the parameter
a1 is the format string.
Non-zero event IDs can also be used to access the
msg string
associated with the
Log.EventDesc that originally
defined the
Log event.
Log_EventId id = Log_getEventId(evt));
if (id != 0) {
String msg = Text_ropeText(id);
System_aprintf(msg, a1, a2, a3, a4);
}
This works because an event's ID is simply an offset into a table
of characters (maintained by the
Text module)
containing the event's msg string.
The arguments a1, a2, etc. are parameters that are to be interpreted
according to the message format string associated with evt.
SEE
LoggerUart_write8() // instance |
|
Process a log event with up to 8 arguments
Void LoggerUart_write8(
LoggerUart_Handle handle,
Log_Event evt,
Types_ModuleId mid,
IArg a1,
IArg a2,
IArg a3,
IArg a4,
IArg a5,
IArg a6,
IArg a7,
IArg a8);
ARGUMENTS
handle
handle of a previously-created LoggerUart instance object
DETAILS
Same as write4 except with 8 arguments rather than 4.
SEE
Instance Convertors |
|
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
Instance Built-Ins |
|
Int LoggerUart_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object