Beispiel #1
0
 /**
  * @param Commit $commit
  * @return Logger
  */
 public static function createLogger(\App\Models\Commit $commit)
 {
     $file = $commit->getLogFilePath();
     if (is_file($file)) {
         unlink($file);
     }
     # create a log channel
     $logger = new Logger('commit.check');
     $defaultLoggerStream = new StreamHandler($file, \Monolog\Logger::DEBUG);
     $defaultLoggerStream->setFormatter(new JsonFormatter());
     $logger->pushHandler($defaultLoggerStream);
     return $logger;
 }
Beispiel #2
0
 /**
  * @param $commit
  * @return array
  */
 private function getLogLines(Commit $commit)
 {
     $lines = [];
     $filePath = $commit->getLogFilePath();
     if (!is_file($filePath)) {
         return $lines;
     }
     $resource = fopen($filePath, 'r');
     while (!feof($resource)) {
         $line = fgets($resource);
         $data = json_decode($line);
         if (empty($data)) {
             continue;
         }
         $lines[] = $data;
     }
     fclose($resource);
     return $lines;
 }