firephp = $instance; $this->formatter = new FirePhpFormatter(); } /** * Write a message to the log. * * @param array $event event data * @return void */ protected function doWrite(array $event) { $firephp = $this->getFirePhp(); if (! $firephp->getEnabled()) { return; } list($line, $label) = $this->formatter->format($event); switch ($event['priority']) { case Logger::EMERG: case Logger::ALERT: case Logger::CRIT: case Logger::ERR: $firephp->error($line, $label); break; case Logger::WARN: $firephp->warn($line, $label); break; case Logger::NOTICE: case Logger::INFO: $firephp->info($line, $label); break; case Logger::DEBUG: $firephp->trace($line); break; default: $firephp->log($line, $label); break; } } /** * Gets the FirePhpInterface instance that is used for logging. * * @return FirePhp\FirePhpInterface * @throws Exception\RuntimeException */ public function getFirePhp() { if (! $this->firephp instanceof FirePhp\FirePhpInterface && ! class_exists('FirePHP') ) { // No FirePHP instance, and no way to create one throw new Exception\RuntimeException('FirePHP Class not found'); } // Remember: class names in strings are absolute; thus the class_exists // here references the canonical name for the FirePHP class if (! $this->firephp instanceof FirePhp\FirePhpInterface && class_exists('FirePHP') ) { // FirePHPService is an alias for FirePHP; otherwise the class // names would clash in this file on this line. $this->setFirePhp(new FirePhp\FirePhpBridge(new FirePHPService())); } return $this->firephp; } /** * Sets the FirePhpInterface instance that is used for logging. * * @param FirePhp\FirePhpInterface $instance A FirePhpInterface instance to set. * @return FirePhp */ public function setFirePhp(FirePhp\FirePhpInterface $instance) { $this->firephp = $instance; return $this; } }