Zum Ende der Metadaten springen
Zum Anfang der Metadaten

The module LoxBerry::Log contains functions for easy logging and notifications. 

The logfile feature enables LoxBerry-integrated logging including logging/debugging filters set by the user. With the shortcut functions it is very easy to create log entries, and filtering corresponding to the users loglevel is done by the module.

The notify features enable notifications in the user interface (the blue and/or red bullets overlaying icons and the navigation bar). 

Inclusion

use LoxBerry::Log;

The module automatically includes the modules

  • LoxBerry::System
  • JSON
  • Time::Piece
  • HTML::Entities
  • File::Basename

  • File::Path

Commands of this modules can directly be accesses without use'ing them. No error occurs, if the are use'd anyway.

See the usage of this module that was especially developed for easy use with LoxBerry.

Global variables

None.

List of severities for logging

LevelNameShortcut functionObject functionUse when
0EmergencyLOGEMERGE$obj->EMERGE... your LoxBerry burns
1AlertLOGALERT$obj->ALERT... if the critical information also needs to be pushed to the user
2CriticalLOGCRIT$obj->CRIT... when user intervention is needed to continue operation
3

Error → Default

LOGERR$obj->ERR

... when an error occurs but

This is the default value in the plugin database

4WarningLOGWARN$obj->WARN... when something is strange but does not stop operation
5NoticeLOGOK$obj->OK... is to inform the user that something went ok
6InformationalLOGINF$obj->INF... additional infos to any status
7DebugLOGDEB$obj->DEB... for heavy debugging that a user normally don't need.

The object functions are called directly to the log object (e.g. if you have multiple logfiles).

The Shortcut functions always log to the default log object (the first log object).

Do not log higher severity levels just because you think the user should know this. 

Functions

LoxBerry::Log::get_logs

Returns the current available logfiles, optional filtered by $package or $package and $name. Returns an array with a hashref to each logfile.

LoxBerry::Log::get_notifications

Reads the notifications, optional filtered by $package or $package and $name. Returns an array with a hashref to each notification.

LoxBerry::Log::get_notifications_html

Returns HTML code that shows all notifications of the specific package, and/or name and type. The HTML includes buttons to delete the notifications.

LoxBerry::Log::new (logging constructor)

Creates a log object to do LoxBerry-specific logging to a logfile or to the standard output (stderr, stdout). The LoxBerry logging module uses the user-defined loglevel from the plugin management, therefore no plugin-own setting and own loglevel-filtering is required.

LoxBerry::Log::notify

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.

LoxBerry::Log::notify_ext

Creates an information or error notification with extended attributes. Use this function, if you want to store more information in your notification than a simple LoxBerry::Log::notify.

Usage of the logging module

Usage of the notification functions


Debugging

To debug the module, use that code in your program:

$LoxBerry::Log::DEBUG = 1;

This will send debugging messages to STDERR.

 
  • Keine Stichwörter