eZDebug Class Reference
[Utility classes]

Advanced debug/log system. More...

List of all members.


Public Methods

 eZDebug ()
 messageName ($messageType)
instance ()
 setHandleType ($type)
 errorHandler ($errno,$errstr,$errfile,$errline)
 setUseExternalCSS ($use)
 setMessageOutput ($output)
 addTimingPoint ($description="")
 write ($string,$verbosityLevel=EZ_LEVEL_NOTICE,$label="")
 isLogFileEnabled ($type)
 messageTypes ()
logFiles ()
 setScriptStart ($mtime=false)
 createAccumulatorGroup ($key,$name=false)
 createAccumulator ($key,$inGroup=false,$name=false)
 accumulatorStart ($key,$inGroup=false,$name=false)
 accumulatorStop ($key)

Static Public Methods

 showMessage ($type)
 showTypes ($types=false)
 writeNotice ($string,$label="")
 writeWarning ($string,$label="")
 writeError ($string,$label="")
 writeDebug ($string,$label="")
 maxLogSize ()
 setMaxLogSize ($size)
 maxLogrotateFiles ()
 setLogrotateFiles ($files)
 rotateLog ($fileName)
 setLogFileEnabled ($enabled,$types=false)
 isDebugEnabled ()
 updateSettings ($settings)
printReport ($newWindow=false,$as_html=true,$returnReport=false)

Private Methods

 writeFile (&$logFileData,&$string,$verbosityLevel)
timeToFloat ($mtime)
printReportInternal ($as_html=true)

Static Private Methods

dumpVariable ($var)

Private Attributes

 DebugStrings = array()
 TimePoints = array()
 Array which contains the time points.

 TmpTimePoints
 Array which contains the temporary time points.

 TimeAccumulatorList = array()
 Array wich contains time accumulators.

 ShowTypes
 Determines which debug messages should be shown.

 HandleType
 Determines what to do with php errors, ignore, fetch or output.

 OutputFormat
 An array of the outputformats for the different debug levels.

 LogFiles
 An array of logfiles used by the debug class with each key being the debug level.

 TimingAccuracy = 4
 How many places behing . should be displayed when showing times.

 PercentAccuracy = 4
 How many places behing . should be displayed when showing percentages.

 UseCSS
 Whether to use external CSS or output own CSS. True if external is to be used.

 MessageOutput
 Determines how messages are output (screen/log).

 MessageTypes
 A list of message types.

 LogFileEnabled
 A map with message types and whether they should do file logging.

 ScriptStart
 The time when the script was started.

 OverrideList
 A list of override directories.


Detailed Description

Advanced debug/log system.

The eZ debug library is used to handle debug information. It can display information on screen and/or write it to log files.

You can enable on-screen debug information for specific IP addresses.

Timing points can be placed in the code to time the different sections of code.

Each debug message can be turned on/off by using the showTypes() function.

PHP error messages can also be shown using setHandleType().

  include_once( "lib/ezutils/classes/ezdebug.php" );

  // write a temporary debug message
  eZDebug::writeDebug( "Test" );

  // write a notice
  eZDebug::writeNotice( "Image found" );

  // write a warning
  eZDebug::writeWarning( "Image not found, using default" );

  // write an error
  eZDebug::writeError( "Object not found, bailing.." );

  // add a timing points
  eZDebug::addTimingPoint( "Module Found" );

  //.... code

  eZDebug::addTimingPoint( "Module loading" );

  // print the results on screen.
  eZDebug::printReport();

Definition at line ezdebug.php.


Constructor & Destructor Documentation

eZDebug::eZDebug  
 

Creates a new debug object.

Definition at line ezdebug.php.

References UseCSS.

Referenced by instance().


Member Function Documentation

eZDebug::accumulatorStart   key,
  inGroup = false,
  name = false
 

Starts an time count for the accumulator $key. You can also specify a name which will be displayed.

Definition at line ezdebug.php.

References isDebugEnabled().

Referenced by eZMySQLDB::query().

eZDebug::accumulatorStop   key
 

Stops a previous time count and adds the total time to the accumulator $key.

Definition at line ezdebug.php.

References writeWarning().

Referenced by eZMySQLDB::query().

eZDebug::addTimingPoint   description = ""
 

Adds a new timing point for the benchmark report.

Definition at line ezdebug.php.

References showMessage().

Referenced by eZTemplate::fetch().

eZDebug::createAccumulator   key,
  inGroup = false,
  name = false
 

Creates a new accumulator entry if one does not already exist and initializes with default data. If $name is not supplied name is taken from $key. If $inGroup is supplied it will place the accumulator under the specified group.

Definition at line ezdebug.php.

References isDebugEnabled().

eZDebug::createAccumulatorGroup   key,
  name = false
 

Creates an accumulator group with key $key and group name $name. If $name is not supplied name is taken from $key.

Definition at line ezdebug.php.

References isDebugEnabled().

Referenced by eZTemplate::eZTemplate().

& eZDebug::dumpVariable   var [static, private]
 

Dumps the variables contents using the dump_var function

Definition at line ezdebug.php.

Referenced by writeWarning().

eZDebug::errorHandler   errno,
  errstr,
  errfile,
  errline
 

Handles PHP errors, creates notice, warning and error messages for the various PHP error types.

Definition at line ezdebug.php.

References writeWarning().

& eZDebug::instance  
 

Will return the current eZDebug object. If no object exists one will be created.

Definition at line ezdebug.php.

References eZDebug().

Referenced by writeWarning().

eZDebug::isDebugEnabled   [static]
 

Returns:
true if debug should be enabled.
Note:
Will return false until the real settings has been updated with updateSettings()

Definition at line ezdebug.php.

Referenced by writeWarning().

eZDebug::isLogFileEnabled   type
 

Returns:
true if the message type $type has logging to file enabled.

Definition at line ezdebug.php.

References LogFileEnabled.

Referenced by writeFile().

& eZDebug::logFiles  
 

Returns an associative array of all the log files used by this class where each key is the debug level (EZ_LEVEL_NOTICE, EZ_LEVEL_WARNING or EZ_LEVEL_ERROR or EZ_LEVEL_DEBUG).

Definition at line ezdebug.php.

References LogFiles.

Referenced by write().

eZDebug::maxLogrotateFiles   [static]
 

Returns:
the maxium number of logrotate files to keep.

Definition at line ezdebug.php.

References maxLogrotateFiles().

Referenced by rotateLog().

eZDebug::maxLogSize   [static]
 

Returns:
the maxium size for a log file in bytes.

Definition at line ezdebug.php.

References maxLogSize().

Referenced by writeFile().

eZDebug::messageName   messageType
 

Returns:
the name of the message type.

Definition at line ezdebug.php.

References instance().

Referenced by eZDebugSetting::isConditionTrue().

eZDebug::messageTypes  
 

Returns:
an array with the available message types.

Definition at line ezdebug.php.

References MessageTypes.

Referenced by setLogFileEnabled().

& eZDebug::printReport   newWindow = false,
  as_html = true,
  returnReport = false
[static]
 

Prints the debug report

Definition at line ezdebug.php.

References eZSys::wwwDir().

& eZDebug::printReportInternal   as_html = true [private]
 

Prints a full debug report with notice, warnings, errors and a timing report.

Definition at line ezdebug.php.

References UseCSS.

eZDebug::rotateLog   fileName [static]
 

Rotates logfiles so the current logfile is backed up, old rotate logfiles are rotated once more and those that exceed maxLogrotateFiles() will be removed. Rotated files will get the extension .1, .2 etc.

Definition at line ezdebug.php.

References maxLogrotateFiles().

Referenced by writeFile().

eZDebug::setHandleType   type
 

Determines how PHP errors are handled. If $type is EZ_HANDLE_TO_PHP all error messages is sent to PHP using trigger_error(), if $type is EZ_HANDLE_FROM_PHP all error messages from PHP is fetched using a custom error handler and output as a usual eZDebug message. If $type is EZ_HANDLE_NONE there is no error exchange between PHP and eZDebug.

Definition at line ezdebug.php.

References instance().

Referenced by writeFile().

eZDebug::setLogFileEnabled   enabled,
  types = false
[static]
 

Enables or disables logging to file for a given message type. If $types is not supplied it will do the operation for all types.

Definition at line ezdebug.php.

References messageTypes().

Referenced by writeFile().

eZDebug::setLogrotateFiles   files [static]
 

Sets the maxium number of logrotate files to keep to $files.

Definition at line ezdebug.php.

eZDebug::setMaxLogSize   size [static]
 

Sets the maxium size for a log file to $size.

Definition at line ezdebug.php.

eZDebug::setMessageOutput   output
 

Determines the way messages are output, the $output parameter is EZ_OUTPUT_MESSAGE_SCREEN and EZ_OUTPUT_MESSAGE_STORE ored together.

Definition at line ezdebug.php.

References MessageOutput.

eZDebug::setScriptStart   mtime = false
 

Sets the time of the start of the script ot $mtime. If $mtime is not supplied it gets the current microtime(). This is used to calculate total execution time and percentages.

Definition at line ezdebug.php.

References timeToFloat().

eZDebug::setUseExternalCSS   use
 

Enables/disables the use of external CSS. If false a <style> tag is output before the debug list. Default is to use internal css.

Definition at line ezdebug.php.

References UseCSS.

eZDebug::showMessage   type [static]
 

Returns true if the message type $type can be shown.

Definition at line ezdebug.php.

References instance().

Referenced by writeWarning().

eZDebug::showTypes   types = false [static]
 

Sets types to be shown to $types and returns the old show types. If $types is not supplied the current value is returned and no change is done. $types is one or more of EZ_SHOW_NOTICE, EZ_SHOW_WARNING, EZ_SHOW_ERROR, EZ_SHOW_TIMING_POINT or'ed together.

Definition at line ezdebug.php.

References ShowTypes.

& eZDebug::timeToFloat   mtime [private]
 

Returns the microtime as a float value. $mtime must be in microtime() format.

Definition at line ezdebug.php.

Referenced by setScriptStart().

eZDebug::updateSettings   settings [static]
 

Updates the settings for debug handling with the settings array $settings. The array must contain the following keys.

  • debug-enabled - boolean which controls debug handling
  • debug-by-ip - boolean which controls IP controlled debugging
  • debug-ip-list - array of IPs which gets debug

Definition at line ezdebug.php.

References setHandleType().

eZDebug::write   string,
  verbosityLevel = EZ_LEVEL_NOTICE,
  label = ""
 

Writes a debug log message.

Definition at line ezdebug.php.

References writeFile().

eZDebug::writeDebug   string,
  label = ""
[static]
 

Writes a debug message.

Definition at line ezdebug.php.

References showMessage().

Referenced by eZDebugSetting::writeDebug().

eZDebug::writeError   string,
  label = ""
[static]
 

Writes a debug error.

Definition at line ezdebug.php.

References showMessage().

Referenced by writeFile().

eZDebug::writeFile &$    logFileData,
&$    string,
  verbosityLevel
[private]
 

Writes the log message $string to the file $fileName.

Definition at line ezdebug.php.

References writeFile().

Referenced by writeFile().

eZDebug::writeNotice   string,
  label = ""
[static]
 

Writes a debug notice.

Definition at line ezdebug.php.

References showMessage().

Referenced by eZDebugSetting::writeNotice().

eZDebug::writeWarning   string,
  label = ""
[static]
 

Writes a debug warning.

Definition at line ezdebug.php.

References showMessage().

Referenced by eZDebugSetting::writeWarning().


Member Data Documentation

eZDebug::DebugStrings = array() [private]
 

String array containing the debug information

Definition at line ezdebug.php.

Referenced by write().


The documentation for this class was generated from the following file:  

Exponential