grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 'joe') * @throws InvalidArgumentException */ public function log($level, $message, array $context = array()) { $log = \LoggerManager::getLogger(); $message = $this->interpolate($message, $context); switch ($level) { case LogLevel::EMERGENCY: /** @noinspection PhpUndefinedMethodInspection */ $log->fatal('[EMERGENCY] ' . $message); break; case LogLevel::ALERT: /** @noinspection PhpUndefinedMethodInspection */ $log->fatal('[ALERT] ' . $message); break; case LogLevel::CRITICAL: /** @noinspection PhpUndefinedMethodInspection */ $log->fatal('[CRITICAL] ' . $message); break; case LogLevel::ERROR: /** @noinspection PhpUndefinedMethodInspection */ $log->fatal('[ERROR] ' . $message); break; case LogLevel::WARNING: /** @noinspection PhpUndefinedMethodInspection */ $log->warn('[WARNING] ' . $message); break; case LogLevel::NOTICE: /** @noinspection PhpUndefinedMethodInspection */ $log->warn('[NOTICE] ' . $message); break; case LogLevel::INFO: /** @noinspection PhpUndefinedMethodInspection */ $log->info('[INFO] ' . $message); break; case LogLevel::DEBUG: /** @noinspection PhpUndefinedMethodInspection */ $log->debug('[DEBUG] ' . $message); break; default: throw new InvalidArgumentException(); } } /** * build a replacement array with braces around the context keys * @param $message * @param array $context * @return string */ private function interpolate($message, array $context = array()) { $replace = array(); if (empty($context)) { return $message; } foreach ($context as $key => $val) { // check that the value can be casted to string if (!is_array($val) && (!is_object($val) || method_exists($val, '__toString'))) { $replace['{' . $key . '}'] = $val; } } return strtr($message, $replace); } }