Skip to end of metadata
Go to start of metadata

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

 

Reads the notifications, optional filtered by $package or $package and $name. Returns an array with a hashref to each notification.This function is exported, therefore you do not need to prefix the function call with LoxBerry::System.


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

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.

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 array element contains a hash with the notification. 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 KeyContent
PACKAGEPackage name
NAMEGroup name
CONTENTRAWThe message of the notification
CONTENTHTMLThe message HTML-encoded. Linefeeds are converted to <br>.
SEVERITY3 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 added

This attributes are automatically added to your notification

You can use them the same way as the other attributes.

DATEISOThis is the ISO 6801 time format (2018-02-18T14:34:56). Use Time::Piece to convert.
DATESTRThis is a date string in the format %d.%m.%Y %H:%M
KEYThe key is a unique key that represents this notification.
_ISPLUGINThis parameter is set, if notify or notify_ext detected a plugin notification
_ISSYSTEMThis parameter is set, if notify or notify_ext detected a system notification

Usage

use LoxBerry::Log;
 
# Filtered to a specific notification group
my @notifications = get_notifications( $lbpplugindir, "notificationname");
 
for my $notification (@notifications ) {
    if ( $notification->{SEVERITY} == 3 ) {
        print STDERR "An error occured at $notification->{DATESTR}.";
    } elsif ( $notification->{SEVERITY} == 6 ) {
        print STDERR "There is an information at $notification->{DATESTR}.";
    }
}

# Check if a specific attribute, set by notify_ext, is present:
for my $notification (@notifications ) {
    next if (! $notification->{myownattribute} );
	
	# Attribute myownattribute is available
	# do stuff with it
}


# Access properties of the first notification of the array
print $notifications[0]->{DATESTR};

  • No labels