note 111264 added to function.debug-backtrace
| From: | nyoung55atthat_google_mail.com | Date: | Thu, 31 Jan 2013 16:31:57 +0000 |
| Subject: | note 111264 added to function.debug-backtrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193466@lists.php.net to get a copy of this message | ||
Here is a function to cleanly output the debug_backtrace to the error_log
<?php
/*
* Send the output from a backtrace to the error_log
* @param string $message Optional message that will be sent the the error_log before the backtrace
*/
function log_trace($message = '') {
$trace = debug_backtrace();
if ($message) {
error_log($message);
}
$caller = array_shift($trace);
$function_name = $caller['function'];
error_log(sprintf('%s: Called from %s:%s', $function_name, $caller['file'],
$caller['line']));
foreach ($trace as $entry_id => $entry) {
$entry['file'] = $entry['file'] ? : '-';
$entry['line'] = $entry['line'] ? : '-';
if (empty($entry['class'])) {
error_log(sprintf('%s %3s. %s() %s:%s', $function_name, $entry_id + 1,
$entry['function'], $entry['file'], $entry['line']));
} else {
error_log(sprintf('%s %3s. %s->%s() %s:%s', $function_name, $entry_id + 1,
$entry['class'], $entry['function'], $entry['file'],
$entry['line']));
}
}
}
----
Server IP: 69.147.83.199
Probable Submitter: 173.161.88.61 (proxied: 205.144.227.170)
----
Manual Page -- http://php.net/manual/en/function.debug-backtrace.php
Edit -- https://master.php.net/note/edit/111264
Del: integrated -- https://master.php.net/note/delete/111264/integrated
Del: useless -- https://master.php.net/note/delete/111264/useless
Del: bad code -- https://master.php.net/note/delete/111264/bad+code
Del: spam -- https://master.php.net/note/delete/111264/spam
Del: non-english -- https://master.php.net/note/delete/111264/non-english
Del: in docs -- https://master.php.net/note/delete/111264/in+docs
Del: other reasons-- https://master.php.net/note/delete/111264
Reject -- https://master.php.net/note/reject/111264
Search -- https://master.php.net/manage/user-notes.php