BlueShoes Application Framework made with PHP http://www.blueshoes.org/


Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: C:/usr/local/lib/php/blueshoes-4.2/core/lang/Bs_Logger.class.php
BlueShoes Application Framework - lang

Bs_Logger

Bs_Logger

Bs_Logger

 

private class Bs_Logger

Bs_Logger
Is the interface to handle the log messages that occure durning theexecution of a program.Bs_Logger is not extended from Bs_Object to keep it more independent andto give Bs_Object the possibility to use this class itself.2 goals:a) To be able to dynamically change the logging behavior, thusmodify filtering add/remove log-targets. even with life systems.(something doesn't work? just log in, change the logger conf file,and see where the code goes through and what happens.)b) Use as little CPU as possable.Use---After an include the pseudo static Object $Bs_Logger is immediatelyavailable and runs a default initialization routine (see below) thatfetches the property file (see below) and sets the default log-dir and DB.Property file settings may be over driven with calls to setDir() and setDb().Default Initialization Routinea) Try to include the property file 'Bs_Logger.conf.php' from$_SERVER['DOCUMENT_ROOT'] . '../Bs_Logger.conf.php'.b) If 'file' is an (active) output target in the property settings thenset the log dir to $_SERVER['DOCUMENT_ROOT'] . '../bs_log/'.Create dir if not existing.c) If 'db' is an active output targetAND the $GLOBALS['bsDb'] object is setAND $this->_APP['db']['main'] is setuse the dsn of $this->_APP['db']['main'] to connect to DB.NOTE: Point c) may seam a little odd but is used to put the logs in DBProperty File2D Array full of information.Every entry represents a log target and an expresion that is matchedwith the log message elements (the msg, msgType, phpFile, ...). Ifthe 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 loggerquits, 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, $phpLine, $phpFunc, $phpFile(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.phptool 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 |+-----------------------------+

Authors
Version4.0.$id$
Copyrightblueshoes.org

 

Public Method Summary

void

Bs_Logger()

Constructor
bool

loadPropertyFile(string $fileAndPath)

bool

loadPropertyArray(array $prop)

Private Method Summary

void

bsLogger_LazyInclude()

This is an attemt to keep Bs_Logger a independent as possable
void

log(string $msg, string $msgType, int $phpLine, [ string $phpFunc, string $phpFile, string $test ])

The log call
mixed

getTargetStatus([ string $targetKey ])

Get the status of the target 'db' or 'dir'. If TURE target seams OK
bool

setDb( &$dsn)

Init the Logger with the DB to write the log-info.
bool

setDir(string $logDir)

Init the Logger with the dir to write the log-files.
void

getError()

Get last error
void

createLogTable([ string $tblName ])

Creates the table for the log entries
void

dropLogTable([ string $tblName ])

Drops the table for the log entries
void

test( $msg, $msgType, $phpLine, $phpFunc, $phpFile, $logProperty)

void

name( $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msgType, $phpLine, string $phpFunc, string $phpFile, string $test)

Warning: documentation is missing.

Private Field Summary

string

$_logProperty

array

$_APP

string

$_targetDirOK

Follwing vars are used to indicate if logging is possable to
string

$_lastError

string

$_logDir

string

$_bsDb

string

$_targetDbOK

Private Constant Summary

BS_LOGGER_VERSION >>4.0.$x$<< Warning: documentation is missing.
BS_LOGGER_PROPFILE >>Bs_Logger.conf.php<< Warning: documentation is missing.
BS_LOG_INT_ERR >>Internal Error<< Warning: documentation is missing.
BS_LOG_INT_USAGE_ERR >>Internal Usage Error<< Warning: documentation is missing.
BS_LOG_INT_MURPHY_ERR >>Internal Murphy Error<< Warning: documentation is missing.
BS_LOG_ERR >>Error<< Warning: documentation is missing.
BS_LOG_USAGE_ERR >>Usage Error<< Warning: documentation is missing.
BS_LOG_MURPHY_ERR >>Murphy Error<< Warning: documentation is missing.
BS_LOG_WARNING >>Warning<< Warning: documentation is missing.
BS_LOG_HACK_WARNING >>Hack Warning<< Warning: documentation is missing.
BS_LOG_INFO >>Info<< Warning: documentation is missing.

Included files Summary, Type: include

$fileAndPath Warning: documentation is missing.

Public Method Details

Bs_Logger

public void Bs_Logger( )

  Constructor
See text in header.

Returns void


loadPropertyFile

public bool loadPropertyFile( string $fileAndPath )

 

Parameter
string $fileAndPath
Returns bool

(see $this->getError() in case you get FALSE)


loadPropertyArray

public bool loadPropertyArray( array $prop )

 

Parameter
array $prop
Returns bool

TRUE


Private Method Details

bsLogger_LazyInclude

private void bsLogger_LazyInclude( )

  This is an attemt to keep Bs_Logger a independent as possable
If no Db is used I don't event try to include the Db-Packagethat may not be available anyway.

Returns void


log

private void log( string $msg, string $msgType, int $phpLine, [ string $phpFunc, string $phpFile, string $test ] )

  The log call

Parameter
string $msg
Keep it short. DB will take max 255 char.
string $msgType
Your free to set what you want, eg ERROR or WARNING or ...
int $phpLine
The __LINE__
string $phpFunc = >>'-?-'<<
The function name (use __FUNCTION__ with PHP 4.3.0)
string $phpFile = >>'-?-'<<
The __FILE__ (only basename will be stored)
string $test = >>FALSE<<
(optional) Default is FALSE. If TRUE will not log; will only set the 'hit' hash.
Returns void


getTargetStatus

private mixed getTargetStatus( [ string $targetKey ] )

  Get the status of the target 'db' or 'dir'. If TURE target seams OK
If FALSE then target had an error on init or is not used.

Parameter
string $targetKey = >>NULL<<
'db' or 'dir' (optional if not set, returns hash)
Returns mixed

bool or hash with bool value for the targets.


setDb

private bool setDb( &$dsn )

  Init the Logger with the DB to write the log-info.

Parameter
&$dsn
Warning: documentation is missing.
Returns bool

TRUE if OK FALSE on error.

See Also getError()

setDir

private bool setDir( string $logDir )

  Init the Logger with the dir to write the log-files.

Parameter
string $logDir
full path (no file) to the log-dir.
Returns bool

TRUE if OK FALSE on error.

See Also getError()

getError

private void getError( )

  Get last error

Returns void


createLogTable

private void createLogTable( [ string $tblName ] )

  Creates the table for the log entries
Connection to the DB must be OK (see setDb).A 'CREATE TABLE IF NOT EXISTS' will be used.NOTE: The table name must end with 'Log'. It will otherwise be appended.

Parameter
string $tblName = >>''<<
The table name to create. *Must* end with 'Log'
Returns void

See Also setDb()

dropLogTable

private void dropLogTable( [ string $tblName ] )

  Drops the table for the log entries
Connection to the DB must be OK (see setDb).A 'DROP TABLE IF EXISTS' will be used.NOTE: The table name must end with 'Log'. It will otherwise be appended.

Parameter
string $tblName = >>''<<
The table name to drop. *Must* end with 'Log'
Returns void

See Also setDb()

test

private void test( $msg, $msgType, $phpLine, $phpFunc, $phpFile, $logProperty )

 

Parameter
$msg
Warning: documentation is missing.
$msgType
Warning: documentation is missing.
$phpLine
Warning: documentation is missing.
$phpFunc
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$logProperty
Warning: documentation is missing.
Returns void


name

private void name( $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $phpFile, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $test, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msg, $msgType, $phpLine, string $phpFunc, string $phpFile, string $test )

 

Warning: documentation is missing.

Parameter
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$phpFile
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$test
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msg
Warning: documentation is missing.
$msgType
Warning: documentation is missing.
$phpLine
Warning: documentation is missing.
string $phpFunc
Warning: documentation is missing.
string $phpFile
Warning: documentation is missing.
string $test
Warning: documentation is missing.
Returns void


Private Field Details

$_logProperty

private string $_logProperty

>>NULL<<



$_APP

private array $_APP

>><<



$_targetDirOK

private string $_targetDirOK

>>FALSE<<

Follwing vars are used to indicate if logging is possable to
the defined target.


$_lastError

private string $_lastError

>>''<<



$_logDir

private string $_logDir

>>NULL<<



$_bsDb

private string $_bsDb

>>NULL<<



$_targetDbOK

private string $_targetDbOK

>>FALSE<<



Private Constant Details

BS_LOGGER_VERSION

define( BS_LOGGER_VERSION, >>4.0.$x$<< )
Case: default: case sensitive



BS_LOGGER_PROPFILE

define( BS_LOGGER_PROPFILE, >>Bs_Logger.conf.php<< )
Case: default: case sensitive



BS_LOG_INT_ERR

define( BS_LOG_INT_ERR, >>Internal Error<< )
Case: default: case sensitive



BS_LOG_INT_USAGE_ERR

define( BS_LOG_INT_USAGE_ERR, >>Internal Usage Error<< )
Case: default: case sensitive



BS_LOG_INT_MURPHY_ERR

define( BS_LOG_INT_MURPHY_ERR, >>Internal Murphy Error<< )
Case: default: case sensitive



BS_LOG_ERR

define( BS_LOG_ERR, >>Error<< )
Case: default: case sensitive



BS_LOG_USAGE_ERR

define( BS_LOG_USAGE_ERR, >>Usage Error<< )
Case: default: case sensitive



BS_LOG_MURPHY_ERR

define( BS_LOG_MURPHY_ERR, >>Murphy Error<< )
Case: default: case sensitive



BS_LOG_WARNING

define( BS_LOG_WARNING, >>Warning<< )
Case: default: case sensitive



BS_LOG_HACK_WARNING

define( BS_LOG_HACK_WARNING, >>Hack Warning<< )
Case: default: case sensitive



BS_LOG_INFO

define( BS_LOG_INFO, >>Info<< )
Case: default: case sensitive



Included Files, Type: include

$fileAndPath

include( $fileAndPath )




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta