Metainformationen zur Seite
LoxBerry::Log::get_notifications
@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
Parameter | Required | Beschreibung |
---|---|---|
$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 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 added | This 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
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};