kalote1984 发表于 2015-10-29 15:57:13

CI框架阻塞在了打印日志

我们项目使用了CI框架,今天突然出现不能访问的情况,分析后发现所有的php都阻塞在了打印日志的地方。我们没有改写CI框架的打印日志的地方,请问那位大侠碰见过CI框架会导致日志打印阻塞。

                // Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
                if (strpos($this->_date_fmt, 'u') !== FALSE)
                {
                        $microtime_full = microtime(TRUE);
                        $microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
                        $date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
                        $date = $date->format($this->_date_fmt);
                }
                else
                {
                        $date = date($this->_date_fmt);
                }

                $message .= $level.' - '.$date.' --> '.$msg."\n";

                flock($fp, LOCK_EX);

                for ($written = 0, $length = strlen($message); $written < $length; $written += $result)
                {
                        if (($result = fwrite($fp, substr($message, $written))) === FALSE)
                        {
                                break;
                        }
                }

                flock($fp, LOCK_UN);
                fclose($fp);


红色的代码行是阻塞的位置。
页: [1]
查看完整版本: CI框架阻塞在了打印日志