本文整理汇总了PHP中Debug::logHandle方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::logHandle方法的具体用法?PHP Debug::logHandle怎么用?PHP Debug::logHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::logHandle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processException
/**
* Logs or displays exception.
* @param Exception
* @param bool is writing to standard output buffer allowed?
* @return void
*/
public static function processException(Exception $exception, $outputAllowed = FALSE)
{
if (self::$logFile) {
error_log("PHP Fatal error: Uncaught {$exception}");
$file = @strftime('%d-%b-%Y %H-%M-%S ', Debug::$time) . strstr(number_format(Debug::$time, 4, '~', ''), '~');
$file = dirname(self::$logFile) . "/exception {$file}.html";
self::$logHandle = @fopen($file, 'x');
if (self::$logHandle) {
ob_start(array(__CLASS__, 'writeFile'), 1);
self::paintBlueScreen($exception);
ob_end_flush();
fclose(self::$logHandle);
}
if (self::$sendEmails) {
self::sendEmail((string) $exception);
}
} elseif (self::$productionMode) {
// be quiet
} elseif (self::$consoleMode) {
// dump to console
if ($outputAllowed) {
echo "{$exception}\n";
foreach (self::$colophons as $callback) {
foreach ((array) call_user_func($callback, 'bluescreen') as $line) {
echo strip_tags($line) . "\n";
}
}
}
} elseif (self::$firebugDetected && self::$ajaxDetected && !headers_sent()) {
// AJAX mode
self::fireLog($exception, self::EXCEPTION);
} elseif ($outputAllowed) {
// dump to browser
self::paintBlueScreen($exception);
} elseif (self::$firebugDetected && !headers_sent()) {
self::fireLog($exception, self::EXCEPTION);
}
}
示例2: processException
/**
* Logs or displays exception.
* @param Exception
* @param bool is writing to standard output buffer allowed?
* @return void
*/
public static function processException(Exception $exception, $outputAllowed = FALSE)
{
if (!self::$enabled) {
return;
} elseif (self::$logFile) {
try {
$hash = md5($exception . (method_exists($exception, 'getPrevious') ? $exception->getPrevious() : (isset($exception->previous) ? $exception->previous : '')));
self::log("PHP Fatal error: Uncaught " . str_replace("Stack trace:\n" . $exception->getTraceAsString(), '', $exception));
foreach (new DirectoryIterator(dirname(self::$logFile)) as $entry) {
if (strpos($entry, $hash)) {
$skip = TRUE;
break;
}
}
$file = dirname(self::$logFile) . "/exception " . @date('Y-m-d H-i-s') . " {$hash}.html";
if (empty($skip) && (self::$logHandle = @fopen($file, 'w'))) {
ob_start();
// double buffer prevents sending HTTP headers in some PHP
ob_start(array(__CLASS__, '_writeFile'), 1);
self::_paintBlueScreen($exception);
ob_end_flush();
ob_end_clean();
fclose(self::$logHandle);
}
if (self::$sendEmails) {
self::sendEmail((string) $exception);
}
} catch (Exception $e) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
echo 'Debug fatal error: ', get_class($e), ': ', ($e->getCode() ? '#' . $e->getCode() . ' ' : '') . $e->getMessage(), "\n";
exit;
}
} elseif (self::$productionMode) {
// be quiet
} elseif (self::$consoleMode) {
// dump to console
if ($outputAllowed) {
echo "{$exception}\n";
}
} elseif (self::$firebugDetected && self::$ajaxDetected && !headers_sent()) {
// AJAX mode
self::fireLog($exception, self::EXCEPTION);
} elseif ($outputAllowed) {
// dump to browser
if (!headers_sent()) {
@ob_end_clean();
while (ob_get_level() && @ob_end_clean()) {
}
if (in_array('Content-Encoding: gzip', headers_list())) {
header('Content-Encoding: identity', TRUE);
}
// override gzhandler
}
self::_paintBlueScreen($exception);
} elseif (self::$firebugDetected && !headers_sent()) {
self::fireLog($exception, self::EXCEPTION);
}
foreach (self::$onFatalError as $handler) {
call_user_func($handler, $exception);
}
}
示例3: exceptionHandler
/**
* Debug exception handler.
*
* @param Exception
* @return void
*/
public static function exceptionHandler(Exception $exception)
{
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (self::$logFile) {
// log to file
error_log("PHP Fatal error: Uncaught {$exception}");
$file = @strftime('%d-%b-%Y %H-%M-%S ', Debug::$time) . strstr(number_format(Debug::$time, 4, '~', ''), '~');
$file = dirname(self::$logFile) . "/exception {$file}.html";
self::$logHandle = @fopen($file, 'x');
if (self::$logHandle) {
ob_start(array(__CLASS__, 'writeFile'), 1);
self::paintBlueScreen($exception);
ob_end_flush();
fclose(self::$logHandle);
}
self::observeErrorLog();
} elseif (!self::$html || isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
// console or AJAX mode
if (self::$useFirebug && !headers_sent()) {
self::fireLog($exception);
} else {
echo "{$exception}\n";
foreach (self::$colophons as $callback) {
foreach ((array) call_user_func($callback, 'bluescreen') as $line) {
echo strip_tags($line) . "\n";
}
}
}
} else {
// dump to screen
while (ob_get_level() && @ob_end_clean()) {
}
self::paintBlueScreen($exception);
exit;
}
}
示例4: processException
static function processException(Exception $exception, $outputAllowed = FALSE)
{
if (!self::$enabled) {
return;
} elseif (self::$logFile) {
try {
$hash = md5($exception . (method_exists($exception, 'getPrevious') ? $exception->getPrevious() : (isset($exception->previous) ? $exception->previous : '')));
error_log("PHP Fatal error: Uncaught {$exception}");
foreach (new DirectoryIterator(dirname(self::$logFile)) as $entry) {
if (strpos($entry, $hash)) {
$skip = TRUE;
break;
}
}
$file = dirname(self::$logFile) . "/exception " . @date('Y-m-d H-i-s') . " {$hash}.html";
if (empty($skip) && (self::$logHandle = @fopen($file, 'x'))) {
ob_start();
ob_start(array(__CLASS__, '_writeFile'), 1);
self::_paintBlueScreen($exception);
ob_end_flush();
ob_end_clean();
fclose(self::$logHandle);
}
if (self::$sendEmails) {
self::sendEmail((string) $exception);
}
} catch (Exception $e) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
echo 'Nette\\Debug fatal error: ', get_class($e), ': ', ($e->getCode() ? '#' . $e->getCode() . ' ' : '') . $e->getMessage(), "\n";
exit;
}
} elseif (self::$productionMode) {
} elseif (self::$consoleMode) {
if ($outputAllowed) {
echo "{$exception}\n";
foreach (self::$colophons as $callback) {
foreach ((array) call_user_func($callback, 'bluescreen') as $line) {
echo strip_tags($line) . "\n";
}
}
}
} elseif (self::$firebugDetected && self::$ajaxDetected && !headers_sent()) {
self::fireLog($exception, self::EXCEPTION);
} elseif ($outputAllowed) {
if (!headers_sent()) {
@ob_end_clean();
while (ob_get_level() && @ob_end_clean()) {
}
if (in_array('Content-Encoding: gzip', headers_list())) {
header('Content-Encoding: identity', TRUE);
}
}
self::_paintBlueScreen($exception);
} elseif (self::$firebugDetected && !headers_sent()) {
self::fireLog($exception, self::EXCEPTION);
}
foreach (self::$onFatalError as $handler) {
call_user_func($handler, $exception);
}
}
示例5: log
/**
* Logs message or exception to file (if set) and sends e-mail notification (if enabled).
* @param string|Exception
* @param int
* @return void
*/
public static function log($message, $priority = self::INFO)
{
if (!self::$logFile) {
return;
}
if ($message instanceof Exception) {
$exception = $message;
$message = "PHP Fatal error: Uncaught exception " . get_class($exception) . " with message '" . $exception->getMessage() . "' in " . $exception->getFile() . ":" . $exception->getLine();
}
error_log(@date('[Y-m-d H-i-s] ') . trim($message) . (self::$source ? ' @ ' . self::$source : '') . PHP_EOL, 3, self::$logFile);
if ($priority === self::ERROR && self::$sendEmails && @filemtime(self::$logFile . '.email-sent') + self::$emailSnooze < time() && @file_put_contents(self::$logFile . '.email-sent', 'sent')) {
// @ - file may not be writable
call_user_func(self::$mailer, $message);
}
if (isset($exception)) {
$hash = md5($exception . (method_exists($exception, 'getPrevious') ? $exception->getPrevious() : (isset($exception->previous) ? $exception->previous : '')));
foreach (new DirectoryIterator(dirname(self::$logFile)) as $entry) {
if (strpos($entry, $hash)) {
$skip = TRUE;
break;
}
}
if (empty($skip) && (self::$logHandle = @fopen(dirname(self::$logFile) . "/exception " . @date('Y-m-d H-i-s') . " {$hash}.html", 'w'))) {
ob_start();
// double buffer prevents sending HTTP headers in some PHP
ob_start(array(__CLASS__, '_writeFile'), 1);
self::_paintBlueScreen($exception);
ob_end_flush();
ob_end_clean();
fclose(self::$logHandle);
}
}
}
示例6: processException
/**
* Logs or displays exception.
* @param Exception
* @param bool is writing to standard output buffer allowed?
* @return void
*/
public static function processException(Exception $exception, $outputAllowed = FALSE)
{
if (!self::$enabled) {
return;
} elseif (self::$logFile) {
error_log("PHP Fatal error: Uncaught {$exception}");
$file = @strftime('%d-%b-%Y %H-%M-%S ', self::$time) . strstr(number_format(self::$time, 4, '~', ''), '~');
$file = dirname(self::$logFile) . "/exception {$file}.html";
self::$logHandle = @fopen($file, 'x');
if (self::$logHandle) {
ob_start(array(__CLASS__, '_writeFile'), 1);
self::_paintBlueScreen($exception);
ob_end_flush();
fclose(self::$logHandle);
}
if (self::$sendEmails) {
self::sendEmail((string) $exception);
}
} elseif (self::$productionMode) {
// be quiet
} elseif (self::$consoleMode) {
// dump to console
if ($outputAllowed) {
echo "{$exception}\n";
foreach (self::$colophons as $callback) {
foreach ((array) call_user_func($callback, 'bluescreen') as $line) {
echo strip_tags($line) . "\n";
}
}
}
} elseif (self::$firebugDetected && self::$ajaxDetected && !headers_sent()) {
// AJAX mode
self::fireLog($exception, self::EXCEPTION);
} elseif ($outputAllowed) {
// dump to browser
if (!headers_sent()) {
@ob_end_clean();
while (ob_get_level() && @ob_end_clean()) {
}
if (in_array('Content-Encoding: gzip', headers_list())) {
header('Content-Encoding: identity', TRUE);
}
// override gzhandler
}
self::_paintBlueScreen($exception);
} elseif (self::$firebugDetected && !headers_sent()) {
self::fireLog($exception, self::EXCEPTION);
}
foreach (self::$onFatalError as $handler) {
call_user_func($handler, $exception);
}
}