From ccaa387d96f431c3d2390d3b2818e72642bf11c6 Mon Sep 17 00:00:00 2001 From: Dave Goodwin Date: Tue, 25 Oct 2011 17:48:25 +0000 Subject: [PATCH] config.php: merge from trunk; suppress _debug write failures git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/branches/1.8@191 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641 --- config.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/config.php b/config.php index d242091ea2..401d789fb7 100644 --- a/config.php +++ b/config.php @@ -28,10 +28,19 @@ } if(!function_exists('_debug')) { - function _debug($string) { + /** + * @param string $string - the message to write to the debug file. + * @param int $up - how far up the call stack we go to; this affects the line number/file name given in logging + */ + function _debug($string, $up = 0) { global $development; if(isset($development) && $development) { - file_put_contents('/tmp/debug.log', date('Y-m-d H:i:s ') . $string . "\n", FILE_APPEND); + // yes, we really don't want to report file write errors if this doesn't work. + $backtrace = debug_backtrace(); + if(isset($backtrace[$up]['file'])) { + $string = $backtrace[$up]['file'] . $backtrace[$up]['line'] . $string; + } + @file_put_contents('/tmp/debug.log', date('Y-m-d H:i:s ') . $string . "\n", FILE_APPEND); } } }