Class: Bs_Logger
Source Location: /core/lang/Bs_Logger.class.php
Is the interface to handle the log messages that occur during the execution of a program.
Author(s):
Version:
- 4.3.$Revision: 1.2 $ $Date: 2003/08/18 20:23:48 $
Copyright:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
[line 118]
Is the interface to handle the log messages that occur during the execution of a program. Bs_Logger is not extended from Bs_Object to keep it more independent and to give Bs_Object the possibility to use this class itself. 2 goals: - To be able to dynamically change the logging behavior, thus
modify filtering add/remove log-targets. even with live systems.
(something doesn't work? just log in, change the logger conf file,
and see where the code goes through and what happens.)
- Use as little CPU as possable.
Use After an include the pseudo static Object $Bs_Logger is immediately available and runs a default initialization routine (see below) that fetches the property file (see below) and sets the default log-dir and DB. Property file settings may be overriden with calls to setDir() and setDb(). Default Initialization Routine - Try to include the property file 'Bs_Logger.conf.php' from
$_SERVER['DOCUMENT_ROOT'] . '../Bs_Logger.conf.php'.
- If 'file' is an (active) output target in the property settings then
set the log dir to $_SERVER['DOCUMENT_ROOT'] . '../bs_log/'.
Create dir if not existing.
- If 'db' is an active output target
AND the $GLOBALS['bsDb'] object is set <= for sam: really? AND? not OR? --andrej
AND $this->_APP['db']['main'] is set
use the dsn of $this->_APP['db']['main'] to connect to DB.
NOTE: Point 3) may seems a little odd but is used to put the logs in DB Property File 2D Array full of information. Every entry represents a log target and an expression that is matched with the log message elements (the msg, msgType, phpFile, ...). If the expresion does *not* match, the next entry is taken for match. If match succeeds the log is written and if 'Hit And Quit' is TRUE the logger quits, otherwise the next entry is matched. The main structure of one entry in 'Bs_Logger.conf.php' is:
$bs_logger_logProperty[] = array (
'active' => FALSE, // If this entry is active or not
'hitNquit' => FALSE, // 'Hit And Quit'. Stop looking for further hits if match is TRUE
'target' => '', // One of 'file' or 'db'
'targetName' => '', // file- or table- name (depens on target above)
'regEx' => 'return (preg_match("/aa.*$/i", $msg) OR eregi("error", $msgType));'
)
The PHP-vars that you may use in the 'regEx' are : $msg, $msgType, $_line_, $_func_, $_file_ (Message, Meassage Type, PHP Line Nr., PHP Function Name and PHP File Name ) By modifying the Bs_Logger.conf.php file by hand or with the BS_LogAdmin.class.php tool we are able to take dynamically influence on the Logger.
How it works:
-------------
Log-call ----*
|
+--V--------------------------------------+
| Bs_Logger.class.php |
| Get global info like SID |
*--> | Filter 1 -match-> write to DB or File |
| | Filter 2 -match-> write to DB or File |
| | : |
| | Filter n -match-> write to DB or File |
include once +-----------------------------------------+
|
+-----------------------------+
|Bs_Logger.conf.php (Property)|
| Holding filters and targets |
+-----------------------------+
Tags:
Class Variables
Class Methods
|