/** * * @param string $message * @param string $tag * @param string $date */ public function log($message, $tag = null, $date = null) { if (!is_null($message) && is_string($message) && trim($message) != '') { if (is_null($date)) { $date = date('Y-m-d H:i:s'); } if (is_null($tag)) { $tag = 'LOG'; } else { $tag = strtoupper($tag); } $fileHandler = new FileHandler(); if (!file_exists(ENV_DIR_LOG) || !is_dir(ENV_DIR_LOG)) { $fileHandler->createDirectory(ENV_DIR_LOG); } $filename = ENV_DIR_LOG . '/' . 'log_' . date('Ymd') . '.txt'; $message = str_replace(PHP_EOL, PHP_EOL . "\t", $message); $log = PHP_EOL . "[{$date}] [{$tag}]: {$message}" . PHP_EOL; $fileHandler->writeFile($filename, $log, 'a'); } }
/** * */ public function render() { if ($this->destroyAllCookies) { if (isset($_SERVER['HTTP_COOKIE'])) { $cookies = explode(';', $_SERVER['HTTP_COOKIE']); foreach ($cookies as $cookie) { $parts = explode('=', $cookie); $name = trim($parts[0]); $this->cookies[] = new Cookie($name, '', time() - 1); } } } elseif (count($this->cookiesToDestroy) > 0) { foreach ($this->cookiesToDestroy as $name) { $this->cookies[] = new Cookie($name, '', time() - 1); } } if (!$this->redirected) { if ($this->cancelCache) { if (trim($this->cache) != '' && $this->cacheExists($this->cache)) { $this->destroyCache($this->cache); } $this->cache = ''; } if (trim($this->cache) != '' && file_exists($this->cache) && !$this->cancelCache) { $content = ob_get_contents(); ob_end_clean(); return $content; } foreach ($this->parameters as $name => $value) { ${$name} = $value; } $allMessages = $this->messages['All']; $errorMessages = $this->messages[Message::Error]; $warningMessages = $this->messages[Message::Warning]; $informationMessages = $this->messages[Message::Information]; $successMessages = $this->messages[Message::Success]; $templateVariables = $this->parameters; $template = templatePath($this->template); if (file_exists($template) && !is_dir($template)) { $templateName = $this->template; require_once $template; } else { if (file_exists($this->template) && !is_dir($this->template)) { $templateName = $this->template; require_once $this->template; } else { require_once 'lightwork/json.php'; } } $contents = ob_get_contents(); ob_end_clean(); if (trim($this->cache) != '' && !$this->cancelCache && !file_exists($this->cache)) { $fileHandler = new FileHandler(); $fileHandler->writeFile($this->cache, $label . $contents); } return $contents; } }