本文整理汇总了PHP中Debugger::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Debugger::getInstance方法的具体用法?PHP Debugger::getInstance怎么用?PHP Debugger::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debugger
的用法示例。
在下文中一共展示了Debugger::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setDebugEnabled
/**
* @param bool|false $flag
* @return $this
*/
public function setDebugEnabled($flag = false)
{
if (!$this->_debugger) {
//只有在debug开启时才实例化debugger,并且不能置于构造方法中,否则形成死循环
$this->_debugger = Debugger::getInstance();
}
$this->_debugger->setEnabled($flag);
return $this;
}
示例2: testOutput
/**
* test output switch to firePHP
*
* @return void
*/
public function testOutput()
{
Debugger::getInstance('DebugKitDebugger');
Debugger::addFormat('fb', array('callback' => 'DebugKitDebugger::fireError'));
Debugger::outputAs('fb');
set_error_handler('ErrorHandler::handleError');
$foo .= '';
restore_error_handler();
$result = $this->firecake->sentHeaders;
$this->assertRegExp('/GROUP_START/', $result['X-Wf-1-1-1-1']);
$this->assertRegExp('/ERROR/', $result['X-Wf-1-1-1-2']);
$this->assertRegExp('/GROUP_END/', $result['X-Wf-1-1-1-5']);
Debugger::getInstance('Debugger');
Debugger::outputAs('html');
}
示例3: __debug
function __debug()
{
$argc = func_num_args();
$args = func_get_args();
if ($argc == 0) {
return false;
}
global $__session;
if (Configure::read() == 0) {
return false;
}
$class = 'CakeSession';
if ($__session === null) {
if (ClassRegistry::isKeySet($class)) {
$__session =& ClassRegistry::getObject($class);
} else {
if (!class_exists($class)) {
App::import('Core', $class);
}
$__session =& new $class();
ClassRegistry::addObject($class, $__session);
}
}
$session =& $__session;
if (!$session->started()) {
$session->start();
}
$debugs = array();
if ($session->check('debug.printable')) {
$debugs = $session->read('debug.printable');
}
$debugger =& Debugger::getInstance();
$trace = $debugger->trace(aa('start', 2, 'format', 'array'));
while ($trace[0]['function'] === __FUNCTION__ || false !== strpos($trace[0]['function'], 'call_user_func')) {
array_shift($trace);
}
$debug = compact('args', 'trace');
$debugs = array_merge($debugs, array($debug));
// debug(compact('prints','args'));
$session->write('debug.printable', $debugs);
return true;
}
示例4: _output
private function _output($sql, $params = array())
{
$unqid = uniqid();
Debugger::getInstance()->timerStart($unqid);
$conn = Database::getConnection();
if ($params) {
$query = $conn->prepare($sql);
$query->execute($params);
$sqlForDebugger = $sql . ' (' . implode(',', $params) . ')';
} else {
$query = $conn->query($sql);
$sqlForDebugger = $sql;
}
if (!$query) {
return false;
}
$return = $query->fetchAll(PDO::FETCH_ASSOC);
Debugger::getInstance()->addSql(array($sqlForDebugger, $query->rowCount(), Debugger::getInstance()->timerEnd($unqid, false)));
return $return;
}
示例5: handleError
/**
* override core one with the following enhancements/fixes:
* - 404s log to a different domain
* - IP, Referer and Browser-Infos are added for better error debugging/tracing
* 2011-12-21 ms
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() === 0) {
return false;
}
$errorConfig = Configure::read('Error');
list($error, $log) = self::mapErrorCode($code);
$debug = Configure::read('debug');
if ($debug) {
$data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
return Debugger::getInstance()->outputError($data);
} else {
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
$message .= self::traceDetails();
}
return CakeLog::write($log, $message);
}
}
示例6: testOutput
/**
* testOutput method
*
* @access public
* @return void
*/
function testOutput()
{
Debugger::invoke(Debugger::getInstance());
$result = Debugger::output(false);
$this->assertEqual($result, '');
$out .= '';
$result = Debugger::output(true);
$this->assertEqual($result[0]['error'], 'Notice');
$this->assertEqual($result[0]['description'], 'Undefined variable: out');
$this->assertPattern('/DebuggerTest::testOutput/', $result[0]['trace']);
$this->assertPattern('/SimpleInvoker::invoke/', $result[0]['trace']);
ob_start();
Debugger::output('txt');
$other .= '';
$result = ob_get_clean();
$this->assertPattern('/Undefined variable: other/', $result);
$this->assertPattern('/Context:/', $result);
$this->assertPattern('/DebuggerTest::testOutput/', $result);
$this->assertPattern('/SimpleInvoker::invoke/', $result);
ob_start();
Debugger::output('html');
$wrong .= '';
$result = ob_get_clean();
$this->assertPattern('/<pre class="cake-debug">.+<\\/pre>/', $result);
$this->assertPattern('/<b>Notice<\\/b>/', $result);
$this->assertPattern('/variable: wrong/', $result);
ob_start();
Debugger::output('js');
$buzz .= '';
$result = ob_get_clean();
$this->assertPattern("/<a href\\='javascript:void\\(0\\);' onclick\\='/", $result);
$this->assertPattern('/<b>Notice<\\/b>/', $result);
$this->assertPattern('/Undefined variable: buzz/', $result);
$this->assertPattern('/<a[^>]+>Code<\\/a>/', $result);
$this->assertPattern('/<a[^>]+>Context<\\/a>/', $result);
set_error_handler('simpleTestErrorHandler');
}
示例7: testGetInstance
/**
* test getInstance.
*
* @access public
* @return void
*/
function testGetInstance()
{
$result = Debugger::getInstance();
$this->assertIsA($result, 'Debugger');
$result = Debugger::getInstance('DebuggerTestCaseDebugger');
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance();
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance('Debugger');
$this->assertIsA($result, 'Debugger');
}
示例8: initDebugger
private function initDebugger()
{
$this->debug = Debugger::getInstance($this->config->get('config.debugger'));
}
示例9: define
define('ROOT', __DIR__ . '/');
define('ROOT_URL', 'http://' . $_SERVER['HTTP_HOST'] . str_replace('index.php', '', $_SERVER['PHP_SELF']));
define('CONTROLLER_DIR', ROOT . '_app/controller/');
define('MODEL_DIR', ROOT . '_app/model/');
define('LIBS_DIR', ROOT . '_app/libs/');
define('VIEW_DIR', ROOT . '_app/view/');
function autoLoad($className)
{
if (file_exists(CONTROLLER_DIR . $className . '.class.php')) {
require CONTROLLER_DIR . $className . '.class.php';
} else {
if (file_exists(MODEL_DIR . $className . '.class.php')) {
require MODEL_DIR . $className . '.class.php';
} else {
if (file_exists(LIBS_DIR . $className . '.class.php')) {
require LIBS_DIR . $className . '.class.php';
}
}
}
}
spl_autoload_register('autoLoad');
$dbg = Debugger::getInstance();
Database::connect("localhost", "root", "", "logger");
//Database::connect("217.16.184.116", "logger", "2A?cc9w3", "logger_db");
$router = new Router($_SERVER['REQUEST_URI'], 'dashboard');
$dbg->dump(array_diff(get_declared_classes(), $predefinedClasses), 'All user defined classes');
$dbg->dump($router, 'Router');
$dbg->dump($_SESSION, 'SESSION');
if (filter_input(INPUT_GET, "debug") == 1) {
$dbg->printAll();
}
示例10: output
/**
* Handles object conversion to debug string.
*
* @param string $var Object to convert
* @access protected
*/
function output($format = 'js')
{
$_this = Debugger::getInstance();
$data = null;
if ($format === true && !empty($_this->__data)) {
$data = $_this->__data;
$_this->__data = array();
$format = false;
}
$_this->_outputFormat = $format;
return $data;
}
示例11: output
/**
* Switches output format, updates format strings
*
* @param string $format Format to use, including 'js' for JavaScript-enhanced HTML, 'html' for
* straight HTML output, or 'txt' for unformatted text.
* @param array $strings Template strings to be used for the output format.
* @access protected
*/
function output($format = null, $strings = array())
{
$_this =& Debugger::getInstance();
$data = null;
if (is_null($format)) {
return $_this->_outputFormat;
}
if (!empty($strings)) {
if (isset($_this->_templates[$format])) {
if (isset($strings['links'])) {
$_this->_templates[$format]['links'] = array_merge($_this->_templates[$format]['links'], $strings['links']);
unset($strings['links']);
}
$_this->_templates[$format] = array_merge($_this->_templates[$format], $strings);
} else {
$_this->_templates[$format] = $strings;
}
return $_this->_templates[$format];
}
if ($format === true && !empty($_this->_data)) {
$data = $_this->_data;
$_this->_data = array();
$format = false;
}
$_this->_outputFormat = $format;
return $data;
}
示例12: getDebugger
protected function getDebugger()
{
return Debugger::getInstance();
}
示例13:
<div id="megaBlock">
<div id="header">
<?php
echo View::factory('element/logo');
?>
</div>
<div id="main">
<?php
echo $content;
?>
</div>
<div class="footerPush"></div>
</div>
<div id="footer">
</div>
<?php
$render = Debugger::getInstance()->render();
if ($render) {
echo '<div class="debug-panel">';
echo $render;
echo '</div>';
}
?>
</body>
</html>
示例14: handleError
/**
* Set as the default error handler by CakePHP. Use Configure::write('Error.handler', $callback), to use your own
* error handling methods. This function will use Debugger to display errors when debug > 0. And
* will log errors to CakeLog, when debug == 0.
*
* You can use Configure::write('Error.level', $value); to set what type of errors will be handled here.
* Stack traces for errors can be enabled with Configure::write('Error.trace', true);
*
* @param int $code Code of error
* @param string $description Error description
* @param string $file File on which error occurred
* @param int $line Line that triggered the error
* @param array $context Context
* @return bool true if error was handled
*/
public static function handleError($code, $description, $file = null, $line = null, $context = null)
{
if (error_reporting() === 0) {
return false;
}
$errorConfig = Configure::read('Error');
list($error, $log) = self::mapErrorCode($code);
if ($log === LOG_ERR) {
return self::handleFatalError($code, $description, $file, $line);
}
$debug = Configure::read('debug');
if ($debug) {
$data = array('level' => $log, 'code' => $code, 'error' => $error, 'description' => $description, 'file' => $file, 'line' => $line, 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file));
return Debugger::getInstance()->outputError($data);
}
$message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']';
#mod blamoo@live.com
$message .= "\nForwarded-For: " . (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : '(None)');
#MOD
$message .= "\nReferer: " . (isset($_SERVER['HTTP_REFERER']) ? "<a href=\"{$_SERVER['HTTP_REFERER']}\">{$_SERVER['HTTP_REFERER']}</a>" : '(None)');
#MOD
$message .= "\nUA: " . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '(None)');
#MOD
$message .= "\nMethod: " . (isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '(None)');
#MOD
if (count($_POST) !== 0) {
$message .= "\nPost: <pre>" . var_export($_POST, true) . '</pre>';
#MOD
}
#endmod
if (!empty($errorConfig['trace'])) {
$trace = Debugger::trace(array('start' => 1, 'format' => 'log'));
$message .= "\nTrace:\n" . $trace . "\n";
}
return CakeLog::write($log, $message);
}
示例15: testOutput
function testOutput()
{
if (file_exists(APP . DS . 'vendors' . DS . 'simpletest' . DS . 'reporter.php')) {
define('SIMPLETESTVENDORPATH', 'APP' . DS . 'vendors');
} else {
define('SIMPLETESTVENDORPATH', 'CORE' . DS . 'vendors');
}
Debugger::invoke(Debugger::getInstance());
$result = Debugger::output(false);
$this->assertEqual($result, '');
$out .= '';
$result = Debugger::output(true);
$expected = array(array('error' => 'Notice', 'code' => '8', 'description' => 'Undefined variable: out', 'line' => '48', 'file' => 'CORE/cake/tests/cases/libs/debugger.test.php', 'context' => array("\$result\t=\tnull"), 'trace' => "DebuggerTest::testOutput() - CORE/cake/tests/cases/libs/debugger.test.php, line 48\nSimpleInvoker::invoke() - " . SIMPLETESTVENDORPATH . "/simpletest/invoker.php, line 68\nSimpleInvokerDecorator::invoke() - " . SIMPLETESTVENDORPATH . "/simpletest/invoker.php, line 126\nSimpleErrorTrappingInvoker::invoke() - " . SIMPLETESTVENDORPATH . "/simpletest/errors.php, line 48\nSimpleInvokerDecorator::invoke() - " . SIMPLETESTVENDORPATH . "/simpletest/invoker.php, line 126\nSimpleExceptionTrappingInvoker::invoke() - " . SIMPLETESTVENDORPATH . "/simpletest/exceptions.php, line 42\nSimpleTestCase::run() - " . SIMPLETESTVENDORPATH . "/simpletest/test_case.php, line 135\nTestSuite::run() - " . SIMPLETESTVENDORPATH . "/simpletest/test_case.php, line 588\nTestSuite::run() - " . SIMPLETESTVENDORPATH . "/simpletest/test_case.php, line 591\nTestManager::runTestCase() - CORE/cake/tests/lib/test_manager.php, line 93\n[main] - APP/webroot/test.php, line 240"));
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected);
ob_start();
Debugger::output('txt');
$other .= '';
$result = ob_get_clean();
$expected = "Notice: 8 :: Undefined variable: other on line 71 of CORE/cake/tests/cases/libs/debugger.test.php\n";
$expected .= 'Context:
$result = array(array("error" => "Notice","code" => 8,"description" => "Undefined variable: out","line" => 48,"file" => "CORE/cake/tests/cases/libs/debugger.test.php","context" => array("$result = null"),"trace" => "DebuggerTest::testOutput() - CORE/cake/tests/cases/libs/debugger.test.php, line 48
SimpleInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 68
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleErrorTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/errors.php, line 48
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleExceptionTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/exceptions.php, line 42
SimpleTestCase::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 135
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 588
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 591
TestManager::runTestCase() - CORE/cake/tests/lib/test_manager.php, line 93
[main] - APP/webroot/test.php, line 240"))
$out = "[empty string]"
$expected = array(array("error" => "Notice","code" => "8","description" => "Undefined variable: out","line" => "48","file" => "CORE/cake/tests/cases/libs/debugger.test.php","context" => array("$result = null"),"trace" => "DebuggerTest::testOutput() - CORE/cake/tests/cases/libs/debugger.test.php, line 48
SimpleInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 68
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleErrorTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/errors.php, line 48
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleExceptionTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/exceptions.php, line 42
SimpleTestCase::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 135
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 588
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 591
TestManager::runTestCase() - CORE/cake/tests/lib/test_manager.php, line 93
[main] - APP/webroot/test.php, line 240"))
';
$expected .= 'Trace:
DebuggerTest::testOutput() - CORE/cake/tests/cases/libs/debugger.test.php, line 71
SimpleInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 68
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleErrorTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/errors.php, line 48
SimpleInvokerDecorator::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/invoker.php, line 126
SimpleExceptionTrappingInvoker::invoke() - ' . SIMPLETESTVENDORPATH . '/simpletest/exceptions.php, line 42
SimpleTestCase::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 135
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 588
TestSuite::run() - ' . SIMPLETESTVENDORPATH . '/simpletest/test_case.php, line 591
TestManager::runTestCase() - CORE/cake/tests/lib/test_manager.php, line 93
[main] - APP/webroot/test.php, line 240';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected);
set_error_handler('simpleTestErrorHandler');
}