$this->_doc->getOption('sub'), 'tpl' => $this->getTemplate('view.tpl') ); $this->_addItem($item); return $this; } protected function _doLogRotate() { if (null === ($expirationTime = $this->getConfig('logExpirationTime'))) { return; } $files = glob(self::_getLogPath() . '/*.txt'); foreach ($files as $file) { $name = pathinfo($file, PATHINFO_FILENAME); if (false === ($time = strtotime($name))) { continue; } if ($time < $expirationTime) { unlink($file); } } } public static function _getLogPath() { return BASE_PATH . '/tmp/sanity-check-log'; } /** * Outputs report for cron * @static * @param object $class * @param string $report * @return void */ public static function writeCronLog($class, $report) { if (!self::isEnabledLog()) { return; } $output = '>>' . get_class($class) . ' ' . date('Y-m-d H:i:s') . PHP_EOL . $report . PHP_EOL . PHP_EOL; if (false !== ($handle = fopen(self::_getLogPath() . '/' . date('Y-m') . '.txt', 'a+'))) { fwrite($handle, $output); fclose($handle); } } public static function isEnabledLog() { if (null === self::$_isEnabledLog) { self::$_isEnabledLog = (bool) Qs_Application::getConfig('sanityCheck')->get('isEnabledLog', false); } return self::$_isEnabledLog; } }