コード例 #1
0
ファイル: Tracks.php プロジェクト: toohamster/ws
 private function pipe($tag, $track)
 {
     $msg = ['tag' => $tag];
     switch ($tag) {
         case self::TAG_INIT:
             $ms = microtime(true);
             $m = explode('.', (string) $ms);
             if (!isset($m[1])) {
                 $m[1] = 0;
             }
             $msg = ['tag' => $tag, 'runtimeId' => Runtime::instance()->id(), 'ms' => $ms, 'date' => date("Ymd H:i:s.{$m[1]}", $m[0]), 'cookies' => isset($_COOKIE) ? $_COOKIE : [], 'sessions' => isset($_SESSION) ? $_SESSION : []];
             break;
         case self::TAG_START:
             if (!empty($track)) {
                 $msg['track'] = $track;
             }
             break;
         case self::TAG_BEFORE:
             if (!empty($track)) {
                 $msg['track'] = $track;
             }
             break;
         case self::TAG_INFO:
             $msg['track'] = $track;
             break;
         case self::TAG_AFTER:
             if (!empty($track)) {
                 $msg['track'] = $track;
             }
             break;
         case self::TAG_ERROR:
             if (!empty($track)) {
                 $msg['track'] = $track;
             }
             break;
         case self::TAG_FINISH:
             if (!empty($track)) {
                 $msg['track'] = $track;
             }
             break;
         case self::TAG_SHUTDOWN:
             $msg = ['tag' => $tag];
             break;
     }
     Env::dump($msg);
 }
コード例 #2
0
ファイル: Container.php プロジェクト: toohamster/ws
 public static function init($options = [])
 {
     static $noinit = true;
     if ($noinit) {
         // 载入 框架默认值
         $config = new Config(require __DIR__ . '/__defaults.php');
         $config->import($options);
         $timezone = $config->get('app.timezone', 'Asia/Chongqing');
         date_default_timezone_set($timezone);
         $config->set('app.runtime_id', Runtime::instance()->id());
         if (!Env::is('cli')) {
             $session = $config->get('app.session_autostart', true);
             if ($session) {
                 session_start();
             }
             header("Content-Type: text/html;charset=utf-8");
         }
         self::$config = $config;
         $noinit = false;
     }
 }
コード例 #3
0
ファイル: AsDebug.php プロジェクト: toohamster/ws
 function __destruct()
 {
     // 进行资源释放
     if (!$this->enable) {
         return;
     }
     if (!is_dir($this->qargs['dir'])) {
         mkdir($this->qargs['dir'], 0700, true);
     }
     $headers = [];
     if (function_exists('getallheaders')) {
         $headers['request'] = getallheaders();
     } else {
         $headers['request'] = self::emu_getallheaders();
     }
     $headers['response'] = headers_list();
     $data = ['url' => Request::get_request_uri(), 'runtimeId' => Runtime::instance()->id(), 'headers' => $headers, 'cookies' => isset($_COOKIE) ? $_COOKIE : [], 'sessions' => isset($_SESSION) ? $_SESSION : [], 'items' => $this->items];
     $create_at = time();
     $id = md5($data['url'] . $create_at);
     $data = json_encode(['id' => $id, 'tag' => $this->qargs['tagval'], 'content' => Env::dump($data, '', true), 'create_at' => date('m-d H:i:s', $create_at)]);
     file_put_contents($this->qargs['logfile'], $data);
 }