Metainformationen zur Seite

LoxBerry::Log::notify

notify($package, $name, $message, ['error']);

Creates an information or error notification that can be displayed in a plugin. This can be used in automated scripts like daemons or cronjobs to notify the user about good or bad news about the status of your plugin.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 show the notification bullet on the plugins page, this needs to be $lbpplugindir.

Inside the package, you can group your notifications by $name. For example, your plugin uses a cronjob and a daemon. Use "cronjob" and "daemon" as names to differentiate these notifications.

The $message is the text that is saved and displayed in the notification.

notify always saves the time you have called notify, so you don't need to place a timestamp in the message.

Parameter

ParameterRequiredBeschreibung
$package x This is, where the message belongs to. In a plugin, always use the variable $lbpplugindir.
$name x The notification group, this notification belongs to.
$message x The message to be sent.
['error'] If you omit this parameter, an informational notification is created.

If the parameter is <> undef, an error is created.
Case sensitivity

The content of PACKAGE and NAME is case-sensitive. If you set the NAME => "Daemon", you have to query "Daemon" in get_notifications and get_notifications_html.

Usage

use LoxBerry::Log;
 
# Create an informational notification for the group "daemon".
notify( $lbpplugindir, "daemon", "The daemon has finished successfully");
 
# Create an error notification for the group "daemon".
notify( $lbpplugindir, "daemon", "The daemon has finished successfully", 1);
notify( $lbpplugindir, "daemon", "The daemon has finished successfully", "error");
# Both calls create an error notification (4th parameter is not undef).

Infos