This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Doubt in migrating Bios 5 LOG Module to LoggerBuf in Sys/Bios 6

The query is regarding the updation of Log Module functionality with the one in Sys/Bios.

In the Existing code, we have something like this:

Existing tcf uses the following:
bios.LOG.create("LOG1");
bios.LOG.instance("LOG1").bufLen = 1024;
bios.LOG.instance("LOG1").comment = "Purpose1";

Usage in C:
LOG_printf(LOG1,"%d %d",(x1),(x2))

bios.LOG.create("LOG2");
bios.LOG.instance("LOG2").bufLen = 8192;
bios.LOG.instance("LOG2").comment = "Purpose2";
Usage in C:
LOG_printf(LOG2,"%d",(x1))

bios.LOG.create("LOG3");
bios.LOG.instance("LOG3").bufLen = 1024;
bios.LOG.instance("LOG3").comment = "Purpose3"
Usage in C:
LOG_printf(LOG3,"%d %d",(x1),x2)

In Sys/Bios, the equivalent of LOG_printf (Log_printf*) does not take LoggerBuf_Handle as an input

macro Void 
Log_print2(Diags_Mask mask, String fmt, IArg a1, IArg a2);

So while using Log_printf in Sys/Bios, how does it know which buffer to write to? In the above example there are 3 choices.

Please comment.

  • Hi Dushyant,

    The Log APIs changed from BIOS5. They offer more flexibility now and at cost of some complexity.

    First of all, the logger is not specified in the Log call. This was an attempt to minimize the number of cycles that it took to complete the Log call. Instead loggers can be tied to modules and/or source files. Any XDC module (e.g. SYS/BIOS' Task or HeapMem) can have a specific logger assigned to it by setting the module's common$.logger setting. There is a special module called Main that sets up all non-XDC modules. So you can create a logger and assign it to Main.common$.logger.

    If you do not want to configure individual modules, you can set Defaults.common$.logger and all un-initialized modules inherit from it.

    SYS/BIOS has a Log example that shows the above functionality.

    Note: If a single logger for all non-XDC modules does not offer enough granularity, you can use the xdc.runtime.Registry module to have an additional logger for non-XDC modules. The Registry module also offers more granularity with the Diags mask settings for non-XDC modules. Please refer to the XDC documentation for more details.

    Todd

  • As per my understanding, with any of the above modules we specify something like

    <Module>.common$.logger = LoggerBuf.create();

    Thus, even with the Registry module, we can use only one loggerbuf.

    How do we use more than one LoggerBuf for a particular module?

    I want to create multiple loggers for different functions.

    -Dushyant

  • Dushyant Sahni said:
    How do we use more than one LoggerBuf for a particular module?

    You cannot have more than one Logger for a particular module.