<?php
namespace Modules\Admin\Server\Logs;

class ModelGenerateReportFluXLogsFilteredL3 extends ModelGenerateReportFluXLogsRaw
{
	/**
	 * Filter the log text
	 * @param string $logStr
	 * @return string
	 */
	protected function filterLog($logStr)
	{
		$logStrArr = explode("\n", $logStr);

		$currentLogLevel = null;
		$ret = [];
		foreach ($logStrArr as $lineStr) {
			$matches = [];
			if (preg_match("/^\[[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+, (?P<logLevel>[0-9])\]/", $lineStr, $matches)) {
				$currentLogLevel = $matches['logLevel'];
			}

			if ($currentLogLevel>=3) {
				$ret[]= $lineStr;
			}
		}

		return implode("\n", $ret);
	}
}
