public function getLogFiles()
    {
        $files = new Finder();
        $files->files()->in(LOG_DIR)->name('*.log')->sortByModifiedTime();
        $logs = array();
        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            $size = $file->getSize() / 8 / 1024;
            $time = date('c', $file->getMTime());
            $dateTime = new \DateTime($time);
            if (!isset($logs[$dateTime->format('Y')])) {
                $logs[$dateTime->format('Y')] = [];
            }
            $logs[$dateTime->format('Y')][$dateTime->format('m')][$time] = [
                'filename' => $file->getFilename(),
                'size' => round($size, 3),
            ];
            krsort($logs[$dateTime->format('Y')][$dateTime->format('m')]);
            krsort($logs[$dateTime->format('Y')]);
        }
        return $logs;
    }
public function getLogFiles()
    {
        $files = new Finder();
        $files->files()->in(LOG_DIR)->name('*.log')->sortByModifiedTime();
        $logs = array();
        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            $size = $file->getSize() / 8 / 1024;
            $time = date('c', $file->getMTime());
            $dateTime = new \DateTime($time);
            if (!isset($logs[$dateTime->format('Y')])) {
                $logs[$dateTime->format('Y')] = [];
            }
            $logs[$dateTime->format('Y')][$dateTime->format('m')][$time] = [
                'filename' => $file->getFilename(),
                'size' => round($size, 3),
            ];
            krsort($logs[$dateTime->format('Y')][$dateTime->format('m')]);
            krsort($logs[$dateTime->format('Y')]);
        }
        return $logs;
    }
public function getLogFiles ( ) { $ files = new Finder ( ) ; $ files -> files ( ) -> in ( LOG_DIR ) -> name ( '*.log' ) -> sortByModifiedTime ( ) ; $ logs = array ( ) ; /** @var \SplFileInfo $file */ foreach ( $ files as $ file ) { $ size = $ file -> getSize ( ) / 8 / 1024 ; $ time = date ( 'c' , $ file -> getMTime ( ) ) ; $ dateTime = new \ DateTime ( $ time ) ; if ( ! isset ( $ logs [ $ dateTime -> format ( 'Y' ) ] ) ) { $ logs [ $ dateTime -> format ( 'Y' ) ] = [ ] ; } $ logs [ $ dateTime -> format ( 'Y' ) ] [ $ dateTime -> format ( 'm' ) ] [ $ time ] = [ 'filename' => $ file -> getFilename ( ) , 'size' => round ( $ size , 3 ) , ] ; krsort ( $ logs [ $ dateTime -> format ( 'Y' ) ] [ $ dateTime -> format ( 'm' ) ] ) ; krsort ( $ logs [ $ dateTime -> format ( 'Y' ) ] ) ; } return $ logs ; }
Servicio que lee los logs y los formatea para listarlos
@return array
Servicio que lee los logs y los formatea para listarlos