Example #1
0
 /**
  * 知识点:
  * debug_backtrace--追踪,返回数组(有当前行号,文件路径)
  * 如:in D:\AppServ\www\myproject\protected\extensions\yii-debug-toolbar\YiiDebugToolbar.php (177)
  * 
  */
 public static function log($msg, $level = CLogger::LEVEL_INFO, $category = 'application')
 {
     if (self::$_logger === null) {
         self::$_logger = new CLogger();
     }
     if (YII_DEBUG && YII_TRACE_LEVEL > 0 && $level !== CLogger::LEVEL_PROFILE) {
         $traces = debug_backtrace();
         $count = 0;
         foreach ($traces as $trace) {
             if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII_PATH) !== 0) {
                 $msg .= "\nin " . $trace['file'] . ' (' . $trace['line'] . ')';
                 if (++$count >= YII_TRACE_LEVEL) {
                     break;
                 }
             }
         }
     }
     self::$_logger->log($msg, $level, $category);
 }
Example #2
0
 public static function setLogger($logger)
 {
     self::$_logger = $logger;
 }
Example #3
0
 /**
  * @return CLogger message logger
  */
 public static function getLogger()
 {
     if (self::$_logger !== null) {
         return self::$_logger;
     } else {
         return self::$_logger = new CLogger();
     }
 }