Helper/File.php
public function getLogFileContent($filename = 'connector')
    {
        switch ($filename) {
            case "connector":
                $filename = 'connector.log';
                break;
            case "system":
                $filename = 'system.log';
                break;
            case "exception":
                $filename = 'exception.log';
                break;
            case "debug":
                $filename = 'debug.log';
                break;
            default:
                return "Log file is not valid. Log file name is " . $filename;
        }
        $pathLogfile = $this->directoryList->getPath('log') . DIRECTORY_SEPARATOR . $filename;
        //tail the length file content
        $lengthBefore = 500000;
        try {
            $contents = '';
            $handle = fopen($pathLogfile, 'r');
            fseek($handle, -$lengthBefore, SEEK_END);
            if (!$handle) {
                return "Log file is not readable or does not exist at this moment. File path is "
                . $pathLogfile;
            }

            if (filesize($pathLogfile) > 0) {
                $contents = fread($handle, filesize($pathLogfile));
                if ($contents === false) {
                    return "Log file is not readable or does not exist at this moment. File path is "
                        . $pathLogfile;
                }
                fclose($handle);
            }
            return $contents;
        } catch (\Exception $e) {
            return $e->getMessage() . $pathLogfile;
        }
    }
public function getLogFileContent($filename = 'connector')
    {
        switch ($filename) {
            case "connector":
                $filename = 'connector.log';
                break;
            case "system":
                $filename = 'system.log';
                break;
            case "exception":
                $filename = 'exception.log';
                break;
            case "debug":
                $filename = 'debug.log';
                break;
            default:
                return "Log file is not valid. Log file name is " . $filename;
        }
        $pathLogfile = $this->directoryList->getPath('log') . DIRECTORY_SEPARATOR . $filename;
        //tail the length file content
        $lengthBefore = 500000;
        try {
            $contents = '';
            $handle = fopen($pathLogfile, 'r');
            fseek($handle, -$lengthBefore, SEEK_END);
            if (!$handle) {
                return "Log file is not readable or does not exist at this moment. File path is "
                . $pathLogfile;
            }

            if (filesize($pathLogfile) > 0) {
                $contents = fread($handle, filesize($pathLogfile));
                if ($contents === false) {
                    return "Log file is not readable or does not exist at this moment. File path is "
                        . $pathLogfile;
                }
                fclose($handle);
            }
            return $contents;
        } catch (\Exception $e) {
            return $e->getMessage() . $pathLogfile;
        }
    }
public function getLogFileContent ( $ filename = 'connector' ) { switch ( $ filename ) { case "connector" : $ filename = 'connector.log' ; break ; case "system" : $ filename = 'system.log' ; break ; case "exception" : $ filename = 'exception.log' ; break ; case "debug" : $ filename = 'debug.log' ; break ; default : return "Log file is not valid. Log file name is " . $ filename ; } $ pathLogfile = $ this -> directoryList -> getPath ( 'log' ) . DIRECTORY_SEPARATOR . $ filename ; //tail the length file content $ lengthBefore = 500000 ; try { $ contents = '' ; $ handle = fopen ( $ pathLogfile , 'r' ) ; fseek ( $ handle , - $ lengthBefore , SEEK_END ) ; if ( ! $ handle ) { return "Log file is not readable or does not exist at this moment. File path is " . $ pathLogfile ; } if ( filesize ( $ pathLogfile ) > 0 ) { $ contents = fread ( $ handle , filesize ( $ pathLogfile ) ) ; if ( $ contents === false ) { return "Log file is not readable or does not exist at this moment. File path is " . $ pathLogfile ; } fclose ( $ handle ) ; } return $ contents ; } catch ( \ Exception $ e ) { return $ e -> getMessage ( ) . $ pathLogfile ; } }
Get log file content.

@param string $filename

@return string
Get log file content .