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.

Masking Log Messages

Expert 2430 points
Other Parts Discussed in Thread: SYSBIOS

I can't seem to get dynamic (run-time) masking to work, i.e., the messages get generated regardless.  So let's just start at the beginning.

Throughout my application, I have hundreds of various Log_printN( Diags_USERM, "" ) statements where I use Diags_USER1 for error messages, Diags_USER2 for trace messages, etc.

What module controls these?  The documentation states (I think) that it's 'xdc.runtime.Main," so put the following in my .cfg file:

var Main = xdc.useModule( 'xdc.runtime.Main' );
Main.common$.diags_USER1 = Diags.RUNTIME_ON;
Main.common$.diags_USER2 = Diags.RUNTIME_ON;
Main.common$.diags_USER3 = Diags.RUNTIME_ON;
Main.common$.diags_USER4 = Diags.RUNTIME_ON;
Main.common$.diags_USER5 = Diags.RUNTIME_ON;
Main.common$.diags_USER6 = Diags.RUNTIME_ON;

And then in my application (in main), I tried the following:

Diags_setMask( "xdc.runtime.Main-2" );

...to turn off the trace messages, but, sadly, they still get generated.  I even tried changing 'Main' to 'Default' to cover EVERY module, but still they show up.  Same thing with the the setMask call, i.e., I used the '%-2' wildcard to turn off ALL USER2 message from all modules, but they still get generated!  What am I doing wrong?

  • Hi Alex,

    I made a quick example and confirmed Diags_setMask works as expected (detailed below).

    Which version of XDC are you using?

    Are you using xdc.runtime.Registry?

    What chip are you running this on?

    Todd

    Example, one and six should be logged the first time thru the loop. one, two,five and six the next times.

    Void tsk0_func(UArg arg0, UArg arg1)
    {
        while (TRUE) {
            Log_print0(Diags_USER1, "one");
            Log_print0(Diags_USER2, "two");
            Log_print0(Diags_USER3, "three");
            Log_print0(Diags_USER4, "four");
            Log_print0(Diags_USER5, "five");
            Log_print0(Diags_USER6, "six");
            Diags_setMask( "xdc.runtime.Main+2" );
            Diags_setMask( "xdc.runtime.Main+5" );
        }
    }

    Int main(Int argc, Char* argv[])
    {
        Diags_setMask( "xdc.runtime.Main-2" );
        Diags_setMask( "xdc.runtime.Main-3" );
        Diags_setMask( "xdc.runtime.Main-4" );
        Diags_setMask( "xdc.runtime.Main-5" );
        BIOS_start();
        return (0);
    }

    logging configuration in .cfg

    var Main = xdc.useModule( 'xdc.runtime.Main' );
    var Diags = xdc.useModule( 'xdc.runtime.Diags' );
    Main.common$.diags_USER1 = Diags.RUNTIME_ON;
    Main.common$.diags_USER2 = Diags.RUNTIME_ON;
    Main.common$.diags_USER3 = Diags.RUNTIME_ON;
    Main.common$.diags_USER4 = Diags.RUNTIME_ON;
    Main.common$.diags_USER5 = Diags.RUNTIME_ON;
    Main.common$.diags_USER6 = Diags.RUNTIME_ON;
    var LoggerBuf = xdc.useModule( 'xdc.runtime.LoggerBuf' );
    var loggerBuf0Params = new LoggerBuf.Params();
    loggerBuf0Params.instance.name = "loggerBuf0";
    Program.global.loggerBuf0 = LoggerBuf.create(loggerBuf0Params);
    Main.common$.logger = Program.global.loggerBuf0;

  • I guess therein lies the problem.  I'm not actually creating a main logger.  I am creating UIA loggers.  Same setup as yours, only I have to use "xdc.useModule('ti.uia.runtime.LoggerCircBuf')," and it is being assigned to my LoggingSetup object ('ti.uia.sysbios.LoggingSetup').

    It seems to have no "common$" component (I get undefined errors), so how do you set the equivalent diags_USER1, diags_USER2, etc. masks for that?

    In other words...

        LoggingSetup.common$.diags_USER1 = Diags.RUNTIME_ON;
        LoggingSetup.common$.diags_USER2 = Diags.RUNTIME_ON;
        LoggingSetup.common$.diags_USER3 = Diags.RUNTIME_ON;
        LoggingSetup.common$.diags_USER4 = Diags.RUNTIME_ON;
        LoggingSetup.common$.diags_USER5 = Diags.RUNTIME_ON;
        LoggingSetup.common$.diags_USER6 = Diags.RUNTIME_ON;

    gives "no property named 'common$'" errors.

    UPDATE:

    I got it to work (just now).  I'm using a fairly lengthy .cfg script (with numerous helper functions), and the problem yesterday was that I inadvertently set the flag variables after I created the logger; hence, why they had no effect. :-)  Or, whatever, I'm dazed right now due to fatigue, so I don't remember the exact sequence. ::-)

    Anyway, right now, I bring in the Main module, set the common$ flags, proceed to create my UIA components and its loggers, and now in my program,...

        Diags_setMask( "xdc.runtime.Main-1" );
        Diags_setMask( "xdc.runtime.Main+1");

    ...work as expected.  Thanks for steering me in the right direction!

  • Hi Alex,

    I'm glad you are using the LoggingSetup module. It was intended to make things easier. I'm a little concerned about your comment of setting the flag variables after the create. It should not matter. Could you attach your .cfg. I'd like to take a look at it.

    Todd

  • <attachment removed due to lack of response>

    Currently, I am setting the flags at line 165.  If I recall correctly, it wasn't working when I added those settings starting at line 252 (after the commented out Default settings).

    Under this Godforsaken Eclipse  external build environment, it's literally a 15 minute endeavor to rebuild my application (3 builds, really, 1 for each core), and I'm under deadline right now, so I don't have the 15 minutes to spare to retest it.