Ejemplo n.º 1
0
 public function testLogErrorExcludedByLevel()
 {
     $log = new Slim_Log(new MyWriter());
     $log->setLevel(0);
     $this->assertFalse($log->error('Error'));
 }
 /**
  * Constructor
  * @param   array   $userSettings   Key-Value array of application settings
  * @return  void
  */
 public function __construct($userSettings = array())
 {
     //Setup Slim application
     $this->environment = Slim_Environment::getInstance();
     $this->request = new Slim_Http_Request($this->environment);
     $this->response = new Slim_Http_Response();
     $this->router = new Slim_Router($this->request->getResourceUri());
     $this->settings = array_merge(self::getDefaultSettings(), $userSettings);
     $this->middleware = array($this);
     $this->add(new Slim_Middleware_Flash());
     $this->add(new Slim_Middleware_MethodOverride());
     //Determine application mode
     $this->getMode();
     //Setup view
     $this->view($this->config('view'));
     //Make default if first instance
     if (is_null(self::getInstance())) {
         $this->setName('default');
     }
     //Set default logger that writes to stderr (may be overridden with middleware)
     $logWriter = $this->config('log.writer');
     if (!$logWriter) {
         $logWriter = new Slim_LogWriter($this->environment['slim.errors']);
     }
     $log = new Slim_Log($logWriter);
     $log->setEnabled($this->config('log.enabled'));
     $log->setLevel($this->config('log.level'));
     $this->environment['slim.log'] = $log;
     //Set global error handler
     set_error_handler(array('Slim', 'handleErrors'));
 }