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. There are five levels of logging, namely

  • INFO - Information log records.
  • DEBUG - Debugging log records.
  • WARN - Warnings
  • ERROR - Errors
  • FATAL - Fatal Errors

Default is 1 and it logs basic information, like date,time and action. Level 2 is comprehensive and detailed. Specially level 3 is good for Sahana administrators and developers who wants to fine tune the applications. The logging level can be altered in the Sahana main configuration file under /conf directory.

Currently logger.inc runs with both MySQL and PostgreSQL and it uses ADO-DB database abstraction layer to co nnect to these databases.

Desgin:

When a function calls a \u201clogger\u201d, it gets information like date,time,action,log level and module it \u2019s being called from, as global variables. It also gets information such as userid and userlogid from the session. Once it collects all the information, it determine the \u201clog level\u201d it has to use for auditing. Depending on th is log level, it stores the values in the database.

          shn_db_insert_array($message);
  • $message: Log message

The message can be chosen from predefined constants as specified in actions.inc, or custom messages can be passed as wel l.

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.


Navigation
QR Code
QR Code dev:logginevent (generated for current page)