コード例 #1
0
 /**
  * 发送邮件
  *
  * @param   $subject    string 邮件主题
  * @param   $body       string 邮件正文
  * @param   $to         string | array 对方
  * @param   $cc         string | array 抄送
  * @param   $bcc        string | array 秘密抄送
  * @return  true | false
  */
 public function sendAsync($subject, $body, $to = '', $cc = '', $bcc = '')
 {
     $params = array('config' => $this->config, 'subject' => $subject, 'body' => $body, 'to' => $to, 'cc' => $cc, 'bcc' => $bcc);
     $gearman = GearmanPool::getClient(GearmanConfig::$SERVER_COMMON);
     $gearman->doBackground('email_async', json_encode($params));
     return true;
 }
コード例 #2
0
ファイル: Logger.class.php プロジェクト: aozhongxu/web_hqoj
 private static function insert($tag, $level, $msg)
 {
     // 是否需要Logger
     if (!GlobalConfig::$LOGGER_ENABLE) {
         return;
     }
     // 临时关闭Logger
     $tmpEnable = GlobalConfig::$LOGGER_ENABLE;
     GlobalConfig::$LOGGER_ENABLE = false;
     // 校验tag
     $tags = LoggerKeys::$allTags;
     if (!in_array($tag, $tags)) {
         throw new LibraryException("TAG:{$tag} 需要在LoggerKeys中定义!");
     }
     // 获取错误信息
     if (is_subclass_of($msg, 'Exception')) {
         $traceList = $msg->getTrace();
         $message = $msg->getMessage();
         $traceInfo = $traceList[0];
         $loc = $traceInfo['file'] . ':' . $traceInfo['line'];
     } else {
         $traceList = debug_backtrace();
         $message = $msg;
         $traceInfo = $traceList[1];
         $loc = $traceInfo['file'] . ':' . $traceInfo['line'];
     }
     $now = time();
     $data = array('create_time' => $now, 'update_time' => $now, 'tag' => $tag, 'level' => $level, 'client_ip' => Http::getClientIp(), 'client_port' => Http::getClientPort(), 'server_ip' => Http::getServerIp(), 'server_port' => Http::getServerPort(), 'url' => Url::getCurrentUrl(), 'post' => json_encode($_POST), 'loc' => $loc, 'message' => $message, 'trace' => json_encode($traceList));
     if (GlobalConfig::$LOGGER_ASYNC) {
         $gearman = GearmanPool::getClient(GearmanConfig::$SERVER_COMMON);
         $gearman->doBackground('logger_async', json_encode($data));
     } else {
         LoggerInterface::save($data);
     }
     GlobalConfig::$LOGGER_ENABLE = $tmpEnable;
 }