LogThat
LogThat provides a easy to use interface for adding diagnostic information into the CPU’s Logger. To use LogThat’s full functionality, a template of type StrExtArgs_typ will need to be declared.
ManageLoggers()
Function deprecated in v1.0.0
This function is used to keep track of all the user defined logbooks.
Direction | Name | Type | Description |
---|---|---|---|
IN | pLoggers | UDINT | This is pointer to an array of the user defined logbooks of type logLogger_typ. |
IN | MaxLoggers | USINT | his defines the max amount of user defined logbooks hat can be present on the CPU. After the max number of logbooks are present, the new logbook will not be created and the ErrorID will be 52802. |
Operation
ManageLoggers( ADR(gLoggers), SIZEOF(gLoggers)/SIZEOF(gLoggers[0]) );
Note: ManageLoggers should be called in CYCLIC and INIT prog.
createLogInit()
Function added in v1.0.0
This function is used create loggers in the init routine.
Direction | Name | Type | Description |
---|---|---|---|
IN | loggerName | STRING | Name of the logger to be created. |
IN | size | UDINT | Size of logger in bytes of the logger |
IN | persistence | LOG_PERSISTENCE_enum | Persistence level of the logger. |
- LOG_PERSISTENCE_VOLATILE - Volatile (DRAM)
- LOG_PERSISTENCE_REMANENT - Resistant to warm restarts (USERRAM)
- LOG_PERSISTENCE_PERSIST - Resistant to cold restarts (USERROM)
Operation
createLogInit("App", 1000000, LOG_PERSISTENCE_VOLATILE);
logInfo(), logWarning(), logError(), logSuccess()
These functions are used to add log entries into the specified logbook. The difference between the functions is the severity of the entry. The Logger categorizes entries as: errors, warnings, successes and information. This library does not support adding successes to the logbook.
StrExtArgs_typ Structure
This structure contains an array of four booleans, integers, strings, and reals. These values can be used in the error string by adding a ‘%’ and the corresponding letter. The error string will be populated with the first member of the array and then will count up based on the error string.
Direction | Name | Type | Description |
---|---|---|---|
In | r | REAL[0..4] | An array of 5 REAL values that can be used to add more description to the logbook entry. |
In | s | UDINT[0..4] | An array of 5 STRING addresses that the value can be used to add more description to the logbook entry. |
In | b | BOOL[0..4] | An array of 5 BOOL values that can be used to add more description to the logbook entry. |
In | i | DINT[0..4] | An array of 5 DINT values that can be used to add more description to the logbook entry. |
Usage
Direction | Name | Type | Description |
---|---|---|---|
IN | loggerName | STRING[LOG_STRLEN_LOGGERNAME] | This input will specify the name of the logbook entries will be added to. If the name does not currently exist and the current number of logBooks is less than the max, a new logbook will be created by Managelogger(). The data then will be added with the specified severity. |
IN | code | UINT | This UINT will be added to the ID field in the logger. |
IN | message | STRING[LOG_STRLEN_LOGGERNAME] | This STRING will be added to the ASCII Data section of the logger. This error sting can include data provided by the MsgData structure. |
IN | pMsgData | StrExtArgs_typ | This is a structure that contains informational data related to the log entry. |
Operation
MsgData.i[0] = gErrorCollector.out.errorCount; // setting the '%i' within the error string
MsgData.b[0] = gErrorCollector.out.error; // setting the '%b' within the error string
logWarning("loggerName", myStruct.out.errorId, "This task has %i , %b errors.", &MsgData);
Errors
- 0 - OK
- 58200 - BRSE_ARL_ID_ALREADY_INITIALIZED
- 58201 - BRSE_ARL_ID_NOT_VALID
- 58202 - BRSE_ARL_BUFFER_FULL
- 58203 - BRSE_ARL_OUT_OF_MEMORY
- 58300 - LOG_ERR_INVALIDINPUT
- 58301 - LOG_ERR_NOTINITIALIZED
- 58302 - LOG_ERR_LOGGERSFULL