The implementation of this logger is fast with minimal stack usage
making it appropriate for a realtime application.
This logger writes all Log events to a circular buffer. As a
result, the execution time of all Log methods bound to this type
of logger are deterministic (and quite short) because there are no
additional memory allocation calls after the circular buffer was
allocated.
If this logger is used in a preemptive environment, then an appropriate
gate must be assigned to the module. For example, if events are generated
from an interrupt context, then a gate that disables interrupts
must be used.
proxy LoggerBuf.TimestampProxy |
|
User supplied time-stamp proxy
XDCscript usage |
meta-domain |
// explicit access to the currently bound delegate module
DETAILS
This proxy allows
LoggerBuf to use a timestamp server different
from the server used by
xdc.runtime.Timestamp. However, if
not supplied by a user, this proxy defaults to whichever timestamp
server is used by
Timestamp.
enum LoggerBuf.BufType |
|
Type of log buffer
XDCscript usage |
meta-domain |
values of type LoggerBuf.BufType
const LoggerBuf.BufType_CIRCULAR;
// The log buffer wraps, overwriting old entries
const LoggerBuf.BufType_FIXED;
// The log buffer halts collection when full
typedef enum LoggerBuf_BufType {
LoggerBuf_BufType_CIRCULAR,
// The log buffer wraps, overwriting old entries
LoggerBuf_BufType_FIXED
// The log buffer halts collection when full
} LoggerBuf_BufType;
metaonly struct LoggerBuf.BasicView |
|
XDCscript usage |
meta-domain |
var obj = new LoggerBuf.BasicView;
obj.label = String ...
obj.lastSerial = Int ...
obj.numEntries = Int ...
obj.type = String ...
obj.enabledFlag = Bool ...
metaonly struct LoggerBuf.RecordView |
|
XDCscript usage |
meta-domain |
var obj = new LoggerBuf.RecordView;
obj.serial = Int ...
obj.timestampRaw = Long ...
obj.modName = String ...
obj.text = String ...
obj.eventId = Int ...
obj.eventName = String ...
obj.arg0 = IArg ...
obj.arg1 = IArg ...
obj.arg2 = IArg ...
obj.arg3 = IArg ...
obj.arg4 = IArg ...
obj.arg5 = IArg ...
obj.arg6 = IArg ...
obj.arg7 = IArg ...
metaonly struct LoggerBuf.StopModeData |
|
This data is added to the RTA MetaData file to support stop mode RTA
XDCscript usage |
meta-domain |
var obj = new LoggerBuf.StopModeData;
obj.bufferSymbol = String ...
obj.bufferSize = Int ...
config LoggerBuf.enableFlush // module-wide |
|
Flush all logs at system exit
XDCscript usage |
meta-domain |
LoggerBuf.enableFlush = Bool false;
extern const Bool LoggerBuf_enableFlush;
metaonly config LoggerBuf.common$ // module-wide |
|
Common module configuration parameters
XDCscript usage |
meta-domain |
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
LoggerBuf.flushAll( ) // module-wide |
|
Flush logs of all instances of LoggerBuf
Void LoggerBuf_flushAll( );
DETAILS
The user is responsible for making sure that no LoggerBuf instances
are created or deleted while in this API, by using an appropriate gate.
metaonly LoggerBuf.getMetaArgs( ) // module-wide |
|
Returns any meta data needed to support RTA
XDCscript usage |
meta-domain |
LoggerBuf.getMetaArgs( Any inst, Any instNum ) returns Any
DETAILS
This meta data should be returned in the form of a structure which
can be converted into XML. This data is added to the RTA XML file
during the application's configuration, and can be accessed later
through the xdc.rta.MetaData module.
The MetaData is returned per instance of the ILogger module. The
instance object is passed to the function as the first argument.
The second argument is the index of the instance in the list of
the ILogger's static instances.
module-wide built-ins |
|
// Get this module's unique id
Bool LoggerBuf_Module_startupDone( );
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool LoggerBuf_Module_hasMask( );
// Test whether this module has a diagnostics mask
Bits16 LoggerBuf_Module_getMask( );
// Returns the diagnostics mask for this module
Void LoggerBuf_Module_setMask( Bits16 mask );
// Set the diagnostics mask for this module
per-instance object types |
|
typedef struct LoggerBuf_Object LoggerBuf_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct LoggerBuf_Struct LoggerBuf_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
per-instance config parameters |
|
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
// Instance config-params object
// The heap that contains the Log buffer for dynamic instances
params.bufSection = String null;
// Section name for the buffer managed by the static instance
// Log buffer type
params.exitFlush = Bool false;
// Flush log at system exit
params.numEntries = Int 64;
// Number of entries in buffer
typedef struct LoggerBuf_Params {
// Instance config-params structure
// Common per-instance configs
// The heap that contains the Log buffer for dynamic instances
// Log buffer type
Bool exitFlush;
// Flush log at system exit
Int numEntries;
// Number of entries in buffer
} LoggerBuf_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
config LoggerBuf.bufHeap // per-instance |
|
The heap that contains the Log buffer for dynamic instances
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
...
DETAILS
The default value
null means the buffer will be allocated from
the
Memory.defaultHeapInstance heap.
config LoggerBuf.bufType // per-instance |
|
Log buffer type
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
...
config LoggerBuf.exitFlush // per-instance |
|
Flush log at system exit
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
...
params.exitFlush = Bool false;
DETAILS
Only used when module parameter
enableFlush is
true.
config LoggerBuf.numEntries // per-instance |
|
Number of entries in buffer
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
...
params.numEntries = Int 64;
DETAILS
Each entry is large enough to store one
Log event containing up to
4 optional arguments. Events containing more than 4 arguments (such
as those from
Log.write5) use 2 entries.
numEntries must be a power of 2.
metaonly config LoggerBuf.bufSection // per-instance |
|
Section name for the buffer managed by the static instance
XDCscript usage |
meta-domain |
var params = new LoggerBuf.Params;
...
params.bufSection = String null;
DETAILS
The default section is the 'dataSection' in the platform.
per-instance creation |
|
XDCscript usage |
meta-domain |
var params =
new LoggerBuf.
Params;
// Allocate instance config-params
params.config = ...
// Assign individual configs
var inst = LoggerBuf.create( params );
// Create an instance-object
// 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)
SEE
per-instance deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
LoggerBuf.disable( ) // per-instance |
|
Disable a log
ARGUMENTS
handle
handle of a previously-created LoggerBuf 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. That allow clients to restore
the previous state.
LoggerBuf.enable( ) // per-instance |
|
Enable a log
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
RETURNS
The function returns the state of the log (TRUE if enabled,
FALSE if disabled) before the call. That allow clients to restore
the previous state.
LoggerBuf.flush( ) // per-instance |
|
Read, clear, and output the contents of the log
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
DETAILS
This method reads, clears, and "prints" each
Log event (via
System.printf) in the log.
LoggerBuf.getNextEntry( ) // per-instance |
|
Fills the passed Log.EventRec with the next entry in the log
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
evtRec
pointer to a supplied EventRec object where the next
entry in the log is copied to
DETAILS
This function is used to read and clear Log events from the
buffer maintained by the LoggerBuf instance. The Log event can
then be transmitted and displayed on a host.
A read pointer is maintained in the
LoggerBuf instance and
points to the next record to read. Entries are not necessarily
returned in chronological order, since buffers of type
BufType_CIRCULAR can wrap.
RETURNS
This function reports the number of entries actually read. The only
values that can be returned are:
- 0 no more entries to read
- 1 or 2 read a complete entry written by write4 or write8
- -1 cleared an incomplete/overwritten entry, more entries to read
LoggerBuf.reset( ) // per-instance |
|
Reset a log to empty state and enable it
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
WARNING
This method is not synchronized with other instance
methods and, as a result, it must never be called when there is a
chance that another instance method is currently in operation or
when another method on this instance may preempt this call.
LoggerBuf.write4( ) // per-instance |
|
Process a log event with up to 4 arguments
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
evt
event to be logged
a1
arbitrary argument passed by caller
This parameter, along with a2, a3, and a4 are parameters
that are to be interpreted according to the message format string
associated with evt.
DETAILS
At the time this method is called,
evt encodes two values: the
module ID of the module that "triggered" a
Log.Event
and the
Log.EventId of the event. The module ID can
be obtained via
Types.getModuleId(evt)
and the event ID can be obtained via
Types.getEventId(evt).
The event ID can be used to compare against other known
Log.Events.
if (Log_getEventId(MY_EVENT) == Types_getEventId(evt)) {
:
}
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.
Types_EventId id = Types_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.
SEE
LoggerBuf.write8( ) // per-instance |
|
Process a log event with up to 8 arguments
Void LoggerBuf_write8(
LoggerBuf_Handle handle,
Types_Event evt,
IArg a1,
IArg a2,
IArg a3,
IArg a4,
IArg a5,
IArg a6,
IArg a7,
IArg a8 );
ARGUMENTS
handle
handle of a previously-created LoggerBuf instance object
DETAILS
Same as write4 except with 8 arguments rather than 4.
SEE
per-instance convertors |
|
// unconditionally move one level up the inheritance hierarchy
// conditionally move one level down the inheritance hierarchy; NULL upon failure
per-instance built-ins |
|
Int LoggerBuf_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