\S+) \S+ \S+ "(?P.*?)" (?P\S+) (?P\S+) "(?P.*?)"/'; /** * PHP format of the time in the log file. * S. https://www.php.net/manual/en/datetime.format.php * * This default format can parse the date in the usageStats plugin's log files. */ public const PHP_DATETIME_FORMAT = 'Y-m-d H:i:s'; /** * Name of the log file that should be converted into the new format. */ public string $fileName; /** * Constructor. * * @param array $argv command-line arguments (see usage) */ public function __construct(array $argv = []) { parent::__construct($argv); if (count($this->argv) != 1) { $this->usage(); exit(8); } $this->fileName = array_shift($this->argv); } /** * Print command usage information. */ public function usage(): void { $archivePath = $this->getLogFileDir(); echo "\nConvert an old usage stats log file.\nThe old usage stats log file needs to be in the folder {$archivePath}.\n\n" . " Usage: php {$this->scriptName} [fileName]\n\n"; } public function getLogFileDir(): string { return StatisticsHelper::getUsageStatsDirPath() . '/' . FileLoader::FILE_LOADER_PATH_ARCHIVE; } public function getParseRegex(): string { return self::PARSEREGEX; } public function getPhpDateTimeFormat(): string { return self::PHP_DATETIME_FORMAT; } public function isPathInfoDisabled(): bool { return self::PATH_INFO_DISABLED; } public function isApacheAccessLogFile(): bool { return false; } /** * Convert the file. */ public function execute(): void { $this->convert($this->fileName); } } $tool = new ConvertUsageStatsLogFile($argv ?? []); $tool->execute();