cchost
[ class tree: cchost ] [ index: cchost ] [ all elements ]

Class: CCDebug

Source Location: /cclib/cc-debug.php

Class Overview


Helper API for debugging the app


Methods



Class Details

[line 50]
Helper API for debugging the app

Error handling state machine:




[ Top ]


Class Methods


method Chronometer [line 319]

float Chronometer( mixed &$CHRONO_STARTTIME)

Works exactly like a stop watch, ie. starts if stopped and stops if started

Based on http://us2.php.net/microtime#50277

Call the function a first time to start the chronometer. The next call to the function will return the number of milliseconds elapsed since the chronometer was started (rounded to three decimal places). The next call will start the chronometer again from where it finished. Multiple timers can be used by creating multiple $timer variables.

  1. CCDebug::Chronometer($timer1);
  2. // DO STUFF HERE
  3. CCDebug::Log('timer1: ' . CCDebug::Chronometer($timer1));
  4.  
  5. CCDebug::Chronometer($timer2);
  6. CCDebug::Chronometer($timer3);
  7.  
  8. // DO SOMETHING
  9. CCDebug::Log('timer3: ' . CCDebug::Chronometer($timer3));
  10. // DO SOMETHING
  11. CCDebug::Log('timer2: ' . CCDebug::Chronometer($timer2));

The $CHRONO_STARTTIME reference paramater does not need to be declared or initialized before use.




Tags:

return:  Void if starting timer, string (in seconds) formatted


Parameters:

mixed   $CHRONO_STARTTIME   Reference to timer var

[ Top ]

method Enable [line 66]

bool Enable( bool $bool)

Set current state of debugging functionality

Debug::Enable(true) Logging of all errors/warning to cc-errors.txt Enables debugging functions like Log, LogVar, PrintVar and StackTrace

Debug::Enable(false) No error logging Disables debugging functions like Log, LogVar, PrintVar and StackTrace




Tags:

return:  Returns previous state of debug enabled flag


Parameters:

bool   $bool   true enables

[ Top ]

method InstallErrorHandler [line 88]

bool InstallErrorHandler( bool $bool)

Installs ccHost custom error handler

Using the ccHost error hanlder can be too strict when including third party libraries (like getID3) and interfacing with outside applications (like phpBB2). It might also cause conflict with other code that wants to set the error handler. Use the QuietErrors/RestoreErrors methods to wrap third party includes and calls.




Tags:

return:  true means error hanlder was already installed, false means no handler was installed
see:  CCDebug::QuietErrors()
see:  CCDebug::Enable()


Parameters:

bool   $bool   true means install ccHost custom error handler

[ Top ]

method IsEnabled [line 118]

bool IsEnabled( )

Get current state of debugging flag



Tags:

return:  true means enabled
see:  CCDebug::Enable()


[ Top ]

method Log [line 261]

void Log( string $msg)

Write stuff to a log

Dumps the results to /cc-log.txt in ccHost directory

This method is only enabled when CCDebug::Enable is frst called with 'true'




Tags:



Parameters:

string   $msg   Use this string to identify what your actually dumping into the log

[ Top ]

method LogErrors [line 222]

void LogErrors( integer $error_mask)

Log errors according the severity

This method uses the same contansts as PHP's error_reporting to determine whether to write out errors to a log file.




Parameters:

integer   $error_mask   Same as php's error_reporting()

[ Top ]

method LogVar [line 241]

void LogVar( string $msg, $var &$var)

The second most useful function in the entire codbase. Display any variable for debugging

Dumps the results to /cc-log.txt in the main directory of the site. Use this method with any variable (include globals like $_REQUEST).

This method is only enabled when CCDebug::Enable is frst called with 'true'




Tags:



Parameters:

string   $msg   Use this string to identify what your actually dumping into the log
$var   &$var   Reference to variable to dump to screen

[ Top ]

method PrintVar [line 190]

void PrintVar( mixed &$var, [bool $template_safe = true])

The most useful function in the entire codbase. Display any variable for debugging

Use this method with any variable (include globals like $_REQUEST)

This method EXITS THE SESSION (!!)

This method is only enabled when CCDebug::Enable is frst called with 'true'




Tags:



Parameters:

mixed   $var   Reference to variable to dump to screen
bool   $template_safe   true means you are NOT debugging code that displays HTML

[ Top ]

method QuietErrors [line 133]

void QuietErrors( [integer $new_level = CC_QUIET_LEVEL])

Tones down the error reporting noise.

Use this to wrap calls to lax 3rd party libraries




Tags:



Parameters:

integer   $new_level   Set the new error_reporting level (default is 0!)

[ Top ]

method RestoreErrors [line 144]

void RestoreErrors( )

Use this to wrap calls to lax 3rd party libraries



Tags:



[ Top ]

method StackTrace [line 160]

void StackTrace( [bool $template_safe = false])

Displays a stack track from where ever this a call to this is placed

This method EXITS THE SESSION (!!)

This method is only enabled when CCDebug::Enable is frst called with 'true'




Tags:



Parameters:

bool   $template_safe   true means you are NOT debugging code that displays HTML

[ Top ]

method _states [line 384]

void &_states( )

Internal buddy



[ Top ]

method _textize [line 367]

void &_textize( mixed &$var)

Internal buddy



[ Top ]


Documentation generated on Sat, 17 Nov 2007 01:03:32 +0000 by phpDocumentor 1.3.0RC4