Esempio n. 1
0
 public static function log(Exception $e)
 {
     //错误日志记录
     if (\Phalcon\DI::getDefault()->getShared('config')->log->file) {
         $logger = new \Phalcon\Logger\Adapter\File(APP_PATH . '/common/logs/' . date('Ymd') . '.log', array('mode' => 'a+'));
         $logger->error(get_class($e) . '[' . $e->getCode() . ']: ' . $e->getMessage());
         $logger->info($e->getFile() . '[' . $e->getLine() . ']');
         $logger->debug("Trace: \n" . $e->getTraceAsString() . "\n");
         $logger->close();
     }
     if (\Phalcon\DI::getDefault()->getShared('config')->log->debug) {
         \App\Controllers\ControllerCommon::instance()->exception($e);
     } else {
         \App\Controllers\ControllerCommon::instance()->exception('系统发生了错误,请联系管理员进行修复,错误代码:' . $e->getCode());
     }
 }