<?php // {{{ includes require_once LIBRARY_PATH . '/FirePHPCore/FirePHP.class.php' ; // }}} function log_message($msg, $level = 'log', $title = '') { static $service = null ; if (is_null($service)) { $service = FLEA::getSingleton('Service_FirePHP') ; /* @var $firePHP FirePHP */ } return $service->appendLog($msg, $level,$title) ; } /** * FirePHP 调试日志服务类 要求PHP5支持* */ class Service_FirePHP extends FirePHP { function __construct(){ parent::__construct(); $errorLevel = explode(',', strtolower(FLEA::getAppInf('logErrorLevel'))); $errorLevel = array_map('trim', $errorLevel); $errorLevel = array_filter($errorLevel, 'trim'); $this->_errorLevel = array(); foreach ($errorLevel as $e) { $this->_errorLevel[$e] = true; } // 定义不同的错误级别对应FirePHP的方法 // 'notice, debug, warning, error, exception, log' $this->_mapping = array( 'log' => 'log' , 'debug' => 'info' , 'notice' => 'info' , 'warning' => 'warn' , 'exception' => 'error' , 'error' => 'error' , ) ; } /** * 追加日志信息 * * @param string $msg * @param string $level */ public function appendLog($msg, $level = 'log', $title = '') { $level = strtolower($level); if (!isset($this->_errorLevel[$level])) { return; } $label = $title ? "{$level}: {$title}" : $level ; if (isset($this->_mapping[$level])){ return $this->{$this->_mapping[$level]}($msg,$label) ; } return $this->log($msg,$label) ; } }
修改
demo图例