module xdc.runtime.LoggerSys

A logger which routes events to the system printf function

This logger processes log events as they are generated and routes them through the System_printf() function. The final disposition of the log event is dependent on which system provider has been assigned to the System.SupportProxy configuration parameter. [ more ... ]
XDCspec summary sourced in xdc/runtime/LoggerSys.xdc
module LoggerSys {  ...
// inherits xdc.runtime.ILogger
    // inherits xdc.runtime.IModule
instance:  ...
C synopsis target-domain
#include <xdc/runtime/LoggerSys.h>
module-wide built-ins
per-instance object types
 
per-instance config parameters
        IInstance_Params *instance;
    } LoggerSys_Params;
 
per-instance creation
per-instance deletion
per-instance functions
    Void LoggerSys_write4// Process a log event with up to 4 arguments( LoggerSys_Handle handle, Types_Event evt, IArg a1, IArg a2, IArg a3, IArg a4 );
    Void LoggerSys_write8// Process a log event with up to 8 arguments( LoggerSys_Handle handle, Types_Event evt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5, IArg a6, IArg a7, IArg a8 );
per-instance convertors
per-instance built-ins
 
XDCscript usage meta-domain
var LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');
local proxy modules
        LoggerSys.TimestampProxy.delegate$ = ITimestampClient.Module null
module-wide config parameters
per-instance config parameters
    var params = new LoggerSys.Params// Instance config-params object;
per-instance creation
    var inst = LoggerSys.create// Create an instance-object( params );
 
XDCspec declarations sourced in xdc/runtime/LoggerSys.xdc
package xdc.runtime;
 
module LoggerSys inherits ILogger {
local proxy modules
    proxy TimestampProxy inherits ITimestampClient;
module-wide config parameters
 
 
instance:
per-instance creation
per-instance functions
    Void write4// Process a log event with up to 4 arguments( Types.Event evt, IArg a1, IArg a2, IArg a3, IArg a4 );
    Void write8// Process a log event with up to 8 arguments( Types.Event evt, IArg a1, IArg a2, IArg a3, IArg a4, IArg a5, IArg a6, IArg a7, IArg a8 );
}
DETAILS
This logger processes log events as they are generated and routes them through the System_printf() function. The final disposition of the log event is dependent on which system provider has been assigned to the System.SupportProxy configuration parameter.
Note that the log events are processed within the runtime context of the Log_write() or Log_print() function that generated the event. It is important to account for the processing overhead and stack usage imposed on the runtime context. The cost of this processing is defined by the implementation of the system provider.
EXAMPLES
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 LoggerSys = xdc.useModule('xdc.runtime.LoggerSys');

  var LoggerSysParams = new LoggerSys.Params();
  Defaults.common$.logger = LoggerSys.create(LoggerSysParams);
  Diags.setMaskMeta("my.pkg.%", Diags.USER1, Diags.RUNTIME_ON);
 
proxy LoggerSys.TimestampProxy

User supplied time-stamp proxy

XDCscript usage meta-domain
LoggerSys.TimestampProxy = ITimestampClient.Module null
// some delegate module inheriting the ITimestampClient interface
    LoggerSys.TimestampProxy.delegate$ = ITimestampClient.Module null
    // explicit access to the currently bound delegate module
 
DETAILS
This proxy allows LoggerSys 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.
 
metaonly config LoggerSys.common$  // module-wide

Common module configuration parameters

XDCscript usage meta-domain
LoggerSys.common$ = Types.Common$ undefined;
 
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.
 
module-wide built-ins

C synopsis target-domain
Types_ModuleId LoggerSys_Module_id( );
// Get this module's unique id
 
Bool LoggerSys_Module_startupDone( );
// Test if this module has completed startup
 
IHeap_Handle LoggerSys_Module_heap( );
// The heap from which this module allocates memory
 
Bool LoggerSys_Module_hasMask( );
// Test whether this module has a diagnostics mask
 
Bits16 LoggerSys_Module_getMask( );
// Returns the diagnostics mask for this module
 
Void LoggerSys_Module_setMask( Bits16 mask );
// Set the diagnostics mask for this module
 
per-instance object types

C synopsis target-domain
typedef struct LoggerSys_Object LoggerSys_Object;
// Opaque internal representation of an instance object
 
typedef LoggerSys_Object *LoggerSys_Handle;
// Client reference to an instance object
 
typedef struct LoggerSys_Struct LoggerSys_Struct;
// Opaque client structure large enough to hold an instance object
 
LoggerSys_Handle LoggerSys_handle( LoggerSys_Struct *structP );
// Convert this instance structure pointer into an instance handle
 
LoggerSys_Struct *LoggerSys_struct( LoggerSys_Handle handle );
// Convert this instance handle into an instance structure pointer
 
per-instance config parameters

XDCscript usage meta-domain
var params = new LoggerSys.Params;
// Instance config-params object
C synopsis target-domain
typedef struct LoggerSys_Params {
// Instance config-params structure
    IInstance_Params *instance;
    // Common per-instance configs
} LoggerSys_Params;
 
Void LoggerSys_Params_init( LoggerSys_Params *params );
// Initialize this config-params structure with supplier-specified defaults before instance creation
 
per-instance creation

XDCscript usage meta-domain
var params = new LoggerSys.Params;
// Allocate instance config-params
params.config =   ...
// Assign individual configs
 
var inst = LoggerSys.create( params );
// Create an instance-object
C synopsis target-domain
LoggerSys_Handle LoggerSys_create( const LoggerSys_Params *params, Error_Block *eb );
// Allocate and initialize a new instance object and return its handle
 
Void LoggerSys_construct( LoggerSys_Struct *structP, const LoggerSys_Params *params );
// 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.
 
per-instance deletion

C synopsis target-domain
Void LoggerSys_delete( LoggerSys_Handle *handleP );
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
 
Void LoggerSys_destruct( LoggerSys_Struct *structP );
// Finalize the instance object inside the provided structure
 
LoggerSys.write4( )  // per-instance

Process a log event with up to 4 arguments

C synopsis target-domain
Void LoggerSys_write4( LoggerSys_Handle handle, Types_Event evt, IArg a1, IArg a2, IArg a3, IArg a4 );
 
ARGUMENTS
handle — handle of a previously-created LoggerSys 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
 
LoggerSys.write8( )  // per-instance

Process a log event with up to 8 arguments

C synopsis target-domain
Void LoggerSys_write8( LoggerSys_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 LoggerSys instance object
DETAILS
Same as write4 except with 8 arguments rather than 4.
SEE
 
per-instance convertors

C synopsis target-domain
ILogger_Handle LoggerSys_Handle_upCast( LoggerSys_Handle handle );
// unconditionally move one level up the inheritance hierarchy
 
LoggerSys_Handle LoggerSys_Handle_downCast( ILogger_Handle handle );
// conditionally move one level down the inheritance hierarchy; NULL upon failure
 
per-instance built-ins

C synopsis target-domain
Int LoggerSys_Object_count( );
// The number of statically-created instance objects
 
LoggerSys_Handle LoggerSys_Object_get( LoggerSys_Object *array, Int i );
// The handle of the i-th statically-created instance object (array == NULL)
 
LoggerSys_Handle LoggerSys_Object_first( );
// The handle of the first dynamically-created instance object, or NULL
 
LoggerSys_Handle LoggerSys_Object_next( LoggerSys_Handle handle );
// The handle of the next dynamically-created instance object, or NULL
 
IHeap_Handle LoggerSys_Object_heap( );
// The heap used to allocate dynamically-created instance objects
 
Types_Label *LoggerSys_Handle_label( LoggerSys_Handle handle, Types_Label *buf );
// The label associated with this instance object
 
String LoggerSys_Handle_name( LoggerSys_Handle handle );
// The name of this instance object
generated on Tue, 01 Sep 2009 00:36:16 GMT