LBLog::get_notifications

@notifications = LBLog::get_notifications([$package], [$name]);

 

Reads the notifications, optional filtered by $package or $package and $name. Returns an array of notifications, containing a labeled array of all attributes of a notification.

LoxBerry 1.0.3

This function is available starting with LoxBerry V1.0.3. If you use that function, set this minimum version in your plugin.cfg.

Use the prefix LBLog:: to access the function.

The $package is the owner of the notification. To get the notifications of your plugin, use the $lbpplugindir variable or the LBPPLUGINDIR constant.

Inside the package, you can filter by the name using the  $name parameter. This must be equal (case-sensitive) to the $name you have specified on setting the notification.

Parameter

ParameterRequiredBeschreibung
$package This is, where the message belongs to. In a plugin, always use the variable $lbpplugindir or constant LBPPLUGINDIR.

Omiting the $package and $name parameter will return all notifications (including system notifications).
$name Filters by the notification group name, this notifications belongs to.

Case sensitivity

The content of $package and $name is case-sensitive. If you set the name => "Daemon", you have to query "Daemon".

Return value

The function returns an array with all found notifications. Every element in the array contains a labeled array with the notification attributes. The labels are case-sensitive, therefore you have to read e.g. the $notification['NAME'] (not $notification['name']).

Each notification also contains all attributes that where set by notify_ext. 


Hash Key Content
PACKAGE Package name
NAME Group name
CONTENTRAW The message of the notification
CONTENTHTML The message HTML-encoded. Linefeeds are converted to <br>.
SEVERITY 3 is an error, 6 is information. Other levels are reserved for future use.
<attribute1>This are your own attributes inserted by notify_ext
<attribute2>This are your own attributes inserted by notify_ext
System addedThis attributes are automatically added to your notification

You can use them the same way as the other attributes.
DATEISO This is the ISO 6801 time format (2018-02-18T14:34:56). Use ''%%Time::Piece%%'' to convert.
DATESTR This is a date string in the format %d.%m.%Y %H:%M
KEY The key is a unique key that represents this notification.
_ISPLUGIN This parameter is set, if notify or notify_ext detected a plugin notification
_ISSYSTEM This parameter is set, if notify or notify_ext detected a system notification

Usage

require_once "loxberry_log.php";
 
# Filtered to a specific notification group
$notifications = LBLog::get_notifications( $lbpplugindir, "notificationname");
 
foreach ($notifications as $notification ) {
    if ( $notification['SEVERITY'] == 3 ) {
        echo "An error occured at {$notification['DATESTR']}.";
    } elseif ( $notification['SEVERITY'] == 6 ) {
        echo "There is an information at {$notification['DATESTR']}.";
    }
}
 
 
# Check if a specific attribute, set by notify_ext, is present:
foreach ($notifications as $notification ) {
    if (! isset($notification['myownattribute']) ) {
        next;
    }
 
    # Attribute myownattribute is available
    # do stuff with it
}