Here is a code which loops through the messages in the current infolog,
static void getWarnings(Args _args)
{
SysInfoLogEnumerator infoLogEnum;
SysInfologMessageStruct infoMessageStruct;
WarningsTable warningsTable;//table to hold the warning
;
warning('It is a warning 01');
warning('It is a warning 02');
warning('It is a warning 03');
infoLogEnum = SysInfoLogEnumerator::newData(infolog.infologData());
while(infoLogEnum.moveNext())
{
infoMessageStruct = SysInfologMessageStruct::construct(infoLogEnum.currentMessage());
warningsTable.Warning = infoMessageStruct.message();
warningsTable.insert();
}
}