ソースを参照

add log time micro

stanley-king 3 年 前
コミット
6f7a1ca1e8
2 ファイル変更8 行追加3 行削除
  1. 3 3
      core/framework/libraries/log.php
  2. 5 0
      test/TestFcgi.php

+ 3 - 3
core/framework/libraries/log.php

@@ -147,7 +147,9 @@ class Log
 
     private function format_msg($message,$level)
     {
-        $now = @date('Y-m-d H:i:s', time());
+        [$micro,$time] = explode(' ',microtime());
+        $now = @date('Y-m-d H:i:s', $time);
+        $now .= sprintf(" %.6f",$micro);
         if(defined('USE_COROUTINE') && USE_COROUTINE === true) {
             $pid = getmypid();
             $cid = Swoole\Coroutine::getCid();
@@ -180,7 +182,6 @@ class Log
 
         if ($this->mAppFile !== false) {
             fwrite($this->mAppFile, $content);
-//            fflush($this->mAppFile);
         }
     }
 
@@ -200,7 +201,6 @@ class Log
 
         if ($this->mAllFile !== false) {
             fwrite($this->mAllFile, $content);
-//            fflush($this->mAllFile);
         }
     }
 

+ 5 - 0
test/TestFcgi.php

@@ -45,4 +45,9 @@ class TestFcgi extends TestCase
             . sprintf('%010d', time())
             . sprintf('%06d', (float)microtime() * 1000000);
     }
+
+    public function testMicroTime()
+    {
+        [$micro,$time] = explode(' ',microtime());
+    }
 }