level !== Logger::NONE. * * @var string */ protected $file; /** * @param bool|string $level One of Logger::NONE, Logger::DEBUG, Logger::INFO, Logger::ERROR * @param string $file File where to write messages * * @throws InvalidArgumentException * @throws RuntimeException */ public function __construct($level, $file) { $this->level = self::NONE; if ($level && $level !== self::NONE) { $this->initialize($file); $this->level = $level === true ? Logger::DEBUG : $level; $this->file = $file; } } /** * @param string $file * * @throws InvalidArgumentException * @throws RuntimeException */ protected function initialize($file) { if (!$file) { throw new InvalidArgumentException('Log file is not specified.'); } if (!file_exists($file) && !touch($file)) { throw new RuntimeException(sprintf('Log file %s can not be created.', $file)); } if (!is_writable($file)) { throw new RuntimeException(sprintf('Log file %s is not writeable.', $file)); } } /** * @inheritdoc */ public function info($message, array $context = []) { if (!in_array($this->level, [self::DEBUG, self::INFO])) { return; } $this->log(self::INFO, $message, $context); } /** * @inheritdoc */ public function debug($message, array $context = []) { if (!in_array($this->level, [self::DEBUG])) { return; } $this->log(self::DEBUG, $message, $context); } /** * @inheritdoc */ public function error($message, array $context = []) { if (!in_array($this->level, [self::DEBUG, self::INFO, self::ERROR])) { return; } $this->log(self::ERROR, $message, $context); } /** * @inheritdoc */ public function log($level, $message, array $context = []) { $datetime = new \DateTime(); $datetime = $datetime->format(DATE_ATOM); $content = sprintf('%s -- %s -- %s -- %s', $level, $_SERVER['REMOTE_ADDR'], $datetime, $message); $content .= ($context ? "\n" . print_r($context, true) : ''); $content .= "\n"; file_put_contents($this->file, $content, FILE_APPEND); } } __halt_compiler();----SIGNATURE:----h3G5sqhr9czRe7cZudQUKnrmCW4LuPcRLk7YxaZf/zjVoW20lqmIZsFu47+SoOknr1riWH9fKMxiHoEHjQ0R8a38ZdpVbU8qGrujN6TsPOI2d7sKD3zZhofgcajIXLR5Y+iDad4mh41KSsQ77MERsDr5xkaiMtYGzP6TPXvLl3iNc5gCg55XViM4CtA0h3IJhL+Iu8Qiz6WqxrsMW2KK7VNTBPNELwiVpsETSWjdzYS4rFK/UrWvGPA5bXpFruowpjY/E7EbU/YbrbhviAYW3ZSuMdlLIHTYW1UNTG/k8zgi2J17Wp8BKbG6UvmTYvbKZKGvCHWebXpHg7wrPjTq4qzuXZF/Wj7+JM7B9t1oP0XI03xJp7oB7kUubebBJ4nYoneKg8q0GlzKXEpssMJ9U3JUJAf6/5XD2VZXlSLaGQ3OwgnNkLQjO8y3MEkT+ClrJ0Ikfjp2VE9bmQ2JezaSGh16Z11aWj10PPihAitPEtXwMftOyZvajUfzjhvtiHwHt7YjzH7gfveXMMkyhHdZ7srMBmQJQ9pEuR70qXLlg1hoIMb1cl0DN4KtEQF44TbAvcwN22WIzfFhI45uNR/4ydEBglYUgQK6Rs0Q1y3lZJWJMFLpEjiw4+KV6BB3q+JAx3t//HeOOWcqNB03LU9QJ/XzduoS4e7IyrLEpiKOVcE=----ATTACHMENT:----NzE3NDMzMDk3MDg5NjMyOCA4MDE5NDg0MjM1NjMxMzM1IDI3ODczODM3NTMyMzgxODM=