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:----rXM3exLwuheykQd9OXsZDodSnoz2+mlNBdM5dGn/f9/UrLNdl0vNbo1egtjAtC4q708sVCAjB26JveXXi7xJ5D+7UDgu8chk5aJ1VNFrepjJlccNjUoWJ/eQ9R/E9Yw7R707grUJR7zYsGZjGFv7zzFzY/ioDnjX8ZBAbcWMHc3nGA8DyLf7dzjPhUCytxQfqXr5f11Y9SkXwBloyiEG21WzAm00YZHvS0DltPwgMg0w4S8qM2ysXxHP7sqIPyOYb2Fbfi68kOaqjpjwc3THeyl/FoDXyY2p10FulJRWznYGmP/Jg1+HQn8Xrw/9DYtByqVtdS1GPyjvwrSIquu340AdtFvnox2M11kfia4c1K+WtE5lYzRNBbMicW3sZM61LrnV1rmaTzLLuW6gFtfaBNCXa9TacMehLunIZpDhylIAQhbNqUAVpJ38cDJ/pDwkdeiche9iDtgnkspm3iyYlT/TCEpBChIcWJrHgdQ/RvKxhTE1f2mCo775M3S2H22dU+V4XuAFIV3B4hgGEcUweIgcWRNyKtw5ir5Ejh1MvyDc5WuXDa6yy+JDHXMznVNbnwNahotnL1NIohD6teeFjWZpmA4wc/KP6ryVbFbGd+z1BwbLg88bp4mkYsMLhnGxEw/89gBD3etLPWxf+NcZuuT1nZgv/6Rz8tO03v2ggEQ=----ATTACHMENT:----NjIyNDg2NTUxNjU3MTk0MCA0NzE5MzQ1MDU0MjkyNTYyIDQyNjQyODQ5MTY1NDYzNTQ=