This is an old revision of the document!
Event Auditing
Name:
lib_log.inc
Synopsis:
shn_log_event()
Description:
This unit is used for auditing/logging purposes in Sahana2. If modules need auditing features, it is a matter of passing values through the functions provided here.
shn_log_event($data_item_UUID=null, $comments, $details=null, $log_level=INFO, $sensitivity_level=NOT_SENSITIVE, $date_time=null, $module=null, $action=null, array $extra_opts=null)
Parameter description.
- data_item_UUID - The UUID of a data item which the log record is related to. (optional)
- comments - A breif log messsage. (required)
- details - A detailed log message. (optional)
- log_level - The log level
- log_sensitivity - The sensitivity of this log message.
- date_time - The date and time in the format returned by php date function - date(“Y-m-d H:i:s”)
- module - The name of the module, if not specified (if null) it will be determined from $global['module']
- action - The name of the action, if not specified (if null) it will be determined from $global['action']
- extra_opts - any extra options as an associate array. This array will be parsed in to key-value pairs in the form of <key>value</key> and will be recorded as text. eg. Longitude, Latitude, etc.
There are five levels of logging, namely
- INFO - Information log records.
- DEBUG - Debugging log records.
- WARN - Warnings
- ERROR - Errors
- FATAL - Fatal Errors
These levels are defined as constants in lib_log.inc
There are eight levels of log sensitivity. The log level defaults to INFO.
- PERSON_SENSITIVE
- ORGANIZATION_SENSITIVE
- LEAGALLY_SENSITIVE
- NATIONAL_SECURITY_SENSITIVE
- SOCIALLY_SENSITIVE
- DISASTER_MITIGATION_SENSITIVE
- SYSTEM_SENSITIVE
- NOT_SENSITIVE
- UNCLASSIFIED
These levels are defined as constants in lib_log.inc
The senisitvity level defaults to NOT_SENSITIVE
Usage:
<?php // Sample code for demonstrate how to use loger... require_once("conf/config.inc"); // get the log level from Sahana2 main config file. require_once("inc/lib_database/db.inc"); // use DB libraries require_once("inc/lib_logger/logger.inc"); // use logger statement_01; statement_02; statement_03; ... statement_n; shn_log_event("UADD"); // calling the logger ?>
Name:
debug.inc
Synopsis:
debug($message)
Description:
Handles Debug messages of Sahana. Especially meant for developers of the system, to be used at development time. Echos
debug messages to either screen or to a file. Can be updated through the configuration file.
Usage:
include inc/lib_logger/debug.inc
debug($message);
where message is the custom message passed
thus, a message of the form: DEBUG: <date><time><message> is echoed.
Author:
Pradeeper and Mifan of Sahana core team.