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:----j7AEwnltC8qNaeI4hhl/4d2HkacyjiFcjgZ5M3I/y5tG3TOrxoZAqJi/CJK5y0BvJ2m/2TuKEDG0ESvmLhIeTjD0F40Ta05eubL/2uaSz7zDtSxxAE0pR0soTunT0UP9NPF+MsrepkhsjBEG7HAwAusAbTNTdI6KC+8WfUPSZbPjXVGI1Q9bJLLnZ42WzRaW/vjrVxrNZErGaBrDAsiV2pJZO1IQj+7YVGpgoRlyUHFzKEmjdecGMEalpn8c/zL5oAz5PD+NwwaBcngMzGXFDQ+aJA/4vBzZXnuCTuhMS74zx/1QdoPf93SG9ZULBiUy0wd2GFDZvZ8eSS7lwWqYgwTzuqsgU8bWBhKsUetwLH162aJ9yckx0hr8zYdYcC7Iwcv2NLNwujqz++dMRreW2TRol9XezwKwD1Jfog5cWokOQTBOm+ZScpCurQRNtYC/lmPqTyXHezic5T9+Jw59wp4e7UzHXSPOmO2NbQ6FDGCX1YU5oZmRe7TrKMNPz4P2XlHho4UD2LAoFSsMHnBJGxMqH514GFYJUi0v7r5T+WlTxpq+ItPwHi7Xgu/Cg3Ne3JRzyCql0TG8Gte+un3IOimzsLipx8aAQGDRgeErGVJf1r/P7527h7e6L6xpRleFvl/PKJkaG+jSJIC8jlN5DcHF3MD+Cbc4Vq40R3HLkX0=----ATTACHMENT:----ODEyNzU4OTEzNTEwMDU5MyAzNzI3MzgwNjY0OTM1ODUwIDQ2MzE0MzE5NDA3MjQ5Mw==