Class: Logger

Source Location: /CORE/system/classes/logger/Logger.php

Class Logger

Class Overview

This Logger can be seen as Abstract implementation and holds all Common methods.

It simply ECHOs the enabled log messages and is NOT meant for debugging/development, NOT for production systems.

It takes a log level within the constructor. This level may be changed during runtime, calling:

  1.  $GLOBALS['LOGGER']->setLogLevel($logLevel);

If no parameter is passed within the constructor, the level will be fetched from the System Configuration:

  1.  $GLOBALS['_BIGACE']['log']['level']

The possible LogLevel are:

  • E_ERROR
  • E_WARNING
  • E_PARSE
  • E_NOTICE
  • E_CORE_ERROR
  • E_CORE_WARNING
  • E_COMPILE_ERROR
  • E_COMPILE_WARNING
  • E_USER_ERROR
  • E_USER_WARNING
  • E_USER_NOTICE
  • E_STRICT (PHP5 - 2048)
  • E_DEBUG (BIGACE specific 1024)
  • E_SQL (BIGACE specific 1025)

Located in /CORE/system/classes/logger/Logger.php [line 63]



		
				Author(s):
		
  • Kevin Papst
Information Tags:
Version:  $Id: Logger.php,v 1.16 2008/11/30 15:12:03 kpapst Exp $
Copyright:  Copyright (C) Kevin Papst
License:  GNU Public License

Properties

Methods

[ Top ]
Descendants
Child Class Description
FileLogger This Logger saves Message to a file.
DBLogger This Logger saves its Message to the Database.
NullLogger This Logger does nothing. It behaves like /dev/null/ ;-)
RuntimeLogger This Logger saves all messages within an internal array. You may fetch these messages at the end of the call and use them for whatever you want (output in html, save to file...).

[ Top ]
Property Summary
mixed   $logLevel  

[ Top ]
Method Summary
Logger   Logger()   Create a new Logger instance with the given Log Level.
void   finalize()   Clean up all resources that might be used by this Logger!
String   formatBacktrace()   Formats one Entry of a Backtrace Entry.
void   getDescriptionForMode()   Returns the Description for the given Mode.
void   getErrorLevel()   Returns an array with all error level
int   getLogLevel()   Returns the current LogLevel.
boolean   isDebugEnabled()   Returns if Debugging is enabled.
boolean   isModeEnabled()   Returns if the given Mode is enabled.
void   log()   Log a message for a special mode, use this if you wanna use your own level/mode!
void   logDebug()   Messages of this Type are most often used for development or error search!
unknown_type   logEntry()   Logs a full LogEntry (which must be an object of the type classes.logger.LogEntry).
void   logError()   Messages of this Type will always be logged!
void   logInfo()   Messages of this Type are used for information messages.
void   logScriptError()   Callback function for the PHP logging mechanism.
void   logSQL()   Only SQL querys should be logged by this function, they have the lowest priority.
void   setLogLevel()   Sets the Level, that defines which Messages will be dumped.

[ Top ]
Properties
mixed   $logLevel = E_ALL [line 71]

[ Top ]
Methods
Constructor Logger  [line 99]

  Logger Logger( [int $logLevel = null]  )

Create a new Logger instance with the given Log Level.

Parameters:
int   $logLevel:  the LogLevel


Redefined in descendants as:

[ Top ]
finalize  [line 314]

  void finalize( )

Clean up all resources that might be used by this Logger!



Redefined in descendants as:

[ Top ]
formatBacktrace  [line 275]

  String formatBacktrace( $backtrace  )

Formats one Entry of a Backtrace Entry.

This method will called in a forach loop, for all entry from debug_backtrace().

Parameters:
   $backtrace: 

API Tags:
Return:  the formatted backtrace entry


[ Top ]
getDescriptionForMode  [line 135]

  void getDescriptionForMode( $mode  )

Returns the Description for the given Mode.

Parameters:
   $mode: 

API Tags:
Access:  protected


[ Top ]
getErrorLevel  [line 110]

  void getErrorLevel( )

Returns an array with all error level



[ Top ]
getLogLevel  [line 127]

  int getLogLevel( )

Returns the current LogLevel.


API Tags:
Return:  the LogLevel


[ Top ]
isDebugEnabled  [line 205]

  boolean isDebugEnabled( )

Returns if Debugging is enabled.

Wrap Debug Calls within an if block for performance issues:

  1.  if ($LOGGER->isDebugEnabled())
  2.  {
  3.        $LOGGER->logDebug('foo');
  4.        $LOGGER->logDebug('bar');
  5.  }


API Tags:
Return:  true if Debug is enabled, otherwise false


Redefined in descendants as:

[ Top ]
isModeEnabled  [line 226]

  boolean isModeEnabled( int $mode  )

Returns if the given Mode is enabled.

Wrap a list of Logger Calls for performance issues inside an if block, if you are sure that the given Level might be deactivated!

  1.  if ($LOGGER->isModeEnabled(E_SQL))
  2.  {
  3.        $LOGGER->log(E_SQL'SELECT * FROM foo');
  4.        $LOGGER->log(E_SQL'SELECT * FROM bar');
  5.  }

Parameters:
int   $mode:  the Mode to check

API Tags:
Return:  true if the Mode is enabled, otherwise false


Redefined in descendants as:

[ Top ]
log  [line 185]

  void log( int $mode, String $msg  )

Log a message for a special mode, use this if you wanna use your own level/mode!

Parameters:
int   $mode:  the Log Level
String   $msg:  the Log Message


Redefined in descendants as:

[ Top ]
logDebug  [line 165]

  void logDebug( String $msg  )

Messages of this Type are most often used for development or error search!

Parameters:
String   $msg:  the Debug Message


Redefined in descendants as:

[ Top ]
logEntry  [line 237]

  unknown_type logEntry( $entry $entry  )

Logs a full LogEntry (which must be an object of the type classes.logger.LogEntry).

Parameters:
$entry   $entry: 


Redefined in descendants as:
  • DBLogger::logEntry() : Logs a full LogEntry (which must be an object of the type classes.logger.LogEntry).

[ Top ]
logError  [line 147]

  void logError( String $msg  )

Messages of this Type will always be logged!

Parameters:
String   $msg:  the Error Message


Redefined in descendants as:

[ Top ]
logInfo  [line 156]

  void logInfo( String $msg  )

Messages of this Type are used for information messages.

Parameters:
String   $msg:  the Info Message


Redefined in descendants as:

[ Top ]
logScriptError  [line 244]

  void logScriptError( $errno, $errmsg, $filename, $linenum, $vars  )

Callback function for the PHP logging mechanism.

Parameters:
   $errno: 
   $errmsg: 
   $filename: 
   $linenum: 
   $vars: 


Redefined in descendants as:

[ Top ]
logSQL  [line 175]

  void logSQL( String $msg, [ $sql = '']  )

Only SQL querys should be logged by this function, they have the lowest priority.

ONLY activate this level for Development or Error Search, NEVER on productive Systems!

Parameters:
String   $msg:  the SQL Command
   $sql: 


Redefined in descendants as:

[ Top ]
setLogLevel  [line 119]

  void setLogLevel( $level  )

Sets the Level, that defines which Messages will be dumped.

Parameters:
   $level: 

API Tags:
See:  config entry $GLOBALS['_BIGACE']['log']['level']

Information Tags:
Final:  

[ Top ]