From RTSC-Pedia

Jump to: navigation, search
revision tip
—— LANDSCAPE orientation
[printable version]  offline version generated on 04-Aug-2010 21:08 UTC  

Using xdc.runtime Logging/Example 4

Adding Logging to RTSC Modules

Contents

Adding Logging to RTSC Modules

There is no need to explicitly add Log statements for method entry, method exit, or instance lifecycle event logging. The RTSC configuration tool automatically inserts the appropriate Log statements necessary to generate these events. So, in the implementation of a RTSC module, it is only necessary to add Log statements to your code base when you require additional event information; to track major mode changes, to monitor RTOS thread context switches, to log application-specific warnings, etc.

Using Log_write() in lieu of Log_print()

In order to minimize your module's runtime footprint you should use Log_write() in lieu of Log_print(); the format string passed to Log_print() can't be compressed or stored in a section separate from the other C strings in the end user's application. Fortunately, replacing Log_print() statements with Log_write() statements is quite straight forward.

Suppose, for example, that the following Log_print() statement appears in a module named Mod.

 
Log_print1(Diags_USER1, "server CPU load is %d %", serverLoad);

Add the following declaration to the Mod module's specification file (Mod.xdc):

Mod.xdc
 
 
 
 
config Log.Event serverLoadEvent = {
    mask: Diags.USER1,
    msg: "server CPU load is %d %"
};

And replace the Log_print1() statement above with the following:

 
Log_write1(Mod_serverLoadEvent, serverLoad);

See also

Using xdc.runtime Logging/Example 1 Classic "hello world" using Log
Using xdc.runtime Logging/Example 2 Events provided by all RTSC target modules
Using xdc.runtime Logging/Example 3 Adding logging to existing code bases

[printable version]  offline version generated on 04-Aug-2010 21:08 UTC  
Copyright © 2008 The Eclipse Foundation. All Rights Reserved
Views
Personal tools
package reference