[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * This file is part of the symfony package. 5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 /** 12 * 13 * @package symfony 14 * @subpackage log 15 * @author Fabien Potencier <fabien.potencier@symfony-project.com> 16 * @version SVN: $Id: sfWebDebugLogger.class.php 3329 2007-01-23 08:29:34Z fabien $ 17 */ 18 class sfWebDebugLogger 19 { 20 protected 21 $webDebug = null; 22 23 /** 24 * Initializes the web debug logger. 25 * 26 * @param array Logger options 27 */ 28 public function initialize($options = array()) 29 { 30 if (!sfConfig::get('sf_web_debug')) 31 { 32 return; 33 } 34 35 $this->webDebug = sfWebDebug::getInstance(); 36 } 37 38 /** 39 * Logs a message. 40 * 41 * @param string Message 42 * @param string Message priority 43 * @param string Message priority name 44 */ 45 public function log($message, $priority, $priorityName) 46 { 47 if (!sfConfig::get('sf_web_debug')) 48 { 49 return; 50 } 51 52 // if we have xdebug, add some stack information 53 $debug_stack = array(); 54 if (function_exists('xdebug_get_function_stack')) 55 { 56 foreach (xdebug_get_function_stack() as $i => $stack) 57 { 58 if ( 59 (isset($stack['function']) && !in_array($stack['function'], array('emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug', 'log'))) 60 || !isset($stack['function']) 61 ) 62 { 63 $tmp = ''; 64 if (isset($stack['function'])) 65 { 66 $tmp .= 'in "'.$stack['function'].'" '; 67 } 68 $tmp .= 'from "'.$stack['file'].'" line '.$stack['line']; 69 $debug_stack[] = $tmp; 70 } 71 } 72 } 73 74 // get log type in {} 75 $type = 'sfOther'; 76 if (preg_match('/^\s*{([^}]+)}\s*(.+?)$/', $message, $matches)) 77 { 78 $type = $matches[1]; 79 $message = $matches[2]; 80 } 81 82 // build the object containing the complete log information. 83 $logEntry = array( 84 'priority' => $priority, 85 'priorityString' => $priorityName, 86 'time' => time(), 87 'message' => $message, 88 'type' => $type, 89 'debugStack' => $debug_stack, 90 ); 91 92 // send the log object. 93 $this->webDebug->log($logEntry); 94 } 95 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |