« Back to Product

Documentation

UC_GetLogMessageStatistics

 array UC_GetLogMessageStatistics (int $InstanceID) 

Parameters

InstanceID

ID for the Util Control

Returns

An array with the following key => value pairs:

Index Type Description
MessageCustomCount integer Number of messages of type KL_CUSTOM (e.g. from IPS_LogMessage)
MessageDefaultCount integer Number of messages of type KL_MESSAGE
MessageErrorCount integer Number of messages of type KL_ERROR
MessageNotifyCount integer Number of messages of type KL_NOTIFY
MessageSuccessCount integer Number of messages of type KL_SUCCESS
MessageTimeStamp integer Sequence number of the last message (of any type) processed by the Util Control. Not a timestamp!
MessageWarningCount integer Number of messages of type KL_WARNING
ResetTimeStamp integer Unix timestamp from which counting starts (start of IP-Symcon or last call of UC_ResetLogMessageStatistics)

Description

The function returns how many messages per message type have been written to the log since ResetTimeStamp. For this purpose, the Util Control receives all messages of the kernel and counts the log messages. The counters can be queried regularly, e.g. to detect whether new errors or warnings have occurred. The last messages themselves are returned by UC_GetLastLogMessages, the counters are reset with UC_ResetLogMessageStatistics.

Only messages that occur while IP-Symcon is ready are recorded (not during startup and shutdown). Debug messages (KL_DEBUG) are not forwarded and are therefore never recorded, neither are messages that are filtered out by the special switch "LogfileFilter".

Warning

Despite its name, MessageTimeStamp is not a timestamp. The kernel numbers all messages it distributes consecutively since the start (1, 2, 3, ...). MessageTimeStamp is the number of the last message processed by the Util Control and changes with every message, not only with log messages. If no messages are waiting to be processed, the value roughly equals MessageCounter of UC_GetKernelStatistics. It is not reset by UC_ResetLogMessageStatistics.

The ID of the Util Control instance can be determined e.g. with IPS_GetInstanceListByModuleID and the module GUID {B69010EA-96D5-46DF-B885-24821B8C8DBD}. If InstanceID does not exist, the function fails with "Instance #... does not exist", if the instance belongs to another module, with "Instance does not implement this function".

Example

// Determine the ID of the Util Control instance
$id = IPS_GetInstanceListByModuleID('{B69010EA-96D5-46DF-B885-24821B8C8DBD}')[0];

print_r(UC_GetLogMessageStatistics($id));

/* e.g. returns:
Array
(
    [MessageCustomCount] => 0
    [MessageDefaultCount] => 0
    [MessageErrorCount] => 2
    [MessageNotifyCount] => 0
    [MessageSuccessCount] => 1
    [MessageTimeStamp] => 184
    [MessageWarningCount] => 1
    [ResetTimeStamp] => 1700000000
)
*/
Any questions?