slim = $slim; if ($log = $slim->getLog()) { $this->originalLogWriter = $log->getWriter(); $log->setWriter($this); $log->setEnabled(true); } } public function write($message, $level) { if ($this->originalLogWriter) { $this->originalLogWriter->write($message, $level); } $this->addMessage($message, $this->getLevelName($level)); } protected function getLevelName($level) { $map = array( Log::EMERGENCY => LogLevel::EMERGENCY, Log::ALERT => LogLevel::ALERT, Log::CRITICAL => LogLevel::CRITICAL, Log::ERROR => LogLevel::ERROR, Log::WARN => LogLevel::WARNING, Log::NOTICE => LogLevel::NOTICE, Log::INFO => LogLevel::INFO, Log::DEBUG => LogLevel::DEBUG ); return $map[$level]; } public function getName() { return 'slim'; } }