francescoc - 2024-03-16

Hi, I am trying to create a log in my application.
Since I cannot find any documentation regarding modifying the codesys configuration file to be able to log in ms, i tried to create a new log via CmpLog.LogCreate.

Below is the part of the code where I create the logger and write a test string.
In the log tab of codesys I actually see the new log that was created, but it is empty, and in the folder I cannot find any files.
I can't find any detailed documentation.

Can you guys give me support?
Are there any examples?

Thank you

IF NOT FirstCycle THEN 
    LogName:= 'LOGS/TestLog';
    LogOptions.bEnable:= 1;
    LogOptions.iMaxEntries:= 5000;
    LogOptions.iMaxFiles:= 100;
    LogOptions.iMaxFileSize:= 5000;
    LogOptions.szName:= LogName;
    LogOptions.uiType:= CmpLog.LogTypes.LT_TIMESTAMP_RTC_HIGHRES;
    LogOptions.uiFilter:= CmpLog.LogClass.LOG_ALL;
    LogHandle:= CmpLog.LogCreate(pOptions := ADR(LogOptions), pResult:= ADR(Result));
    LogHandle:= CmpLog.LogOpen(pszName:= LogName, pResult:= Result);
    Component_Manager.CMAddComponent2('TestLogNEW', 16#00000001, ADR(udiCmpIdNEW), 0);
    CmpLog.LogAdd2(LogHandle, udiCmpIdNEW, CmpLog.LogClass.LOG_INFO, 1, 1, 'Logger started...'); 
END_IF

IF TestWrite THEN 
    TestWrite:= FALSE;
    CmpLog.LogAdd2(LogHandle, udiCmpIdNEW, CmpLog.LogClass.LOG_INFO, 1, 1, 'Write test'); 
END_IF
 

Last edit: francescoc 2024-03-16