/** * @param array|Zend_Config $config * @return Robo47_Log */ public static function factory($config = array()) { if ($config instanceof Zend_Config) { $config = $config->toArray(); } if (!is_array($config) || empty($config)) { $message = 'Configuration must be an array or ' . 'instance of Zend_Config'; throw new Robo47_Log_Exception($message); } $log = new Robo47_Log(); if (!is_array(current($config))) { $log->addWriter(current($config)); } else { foreach ($config as $writer) { $log->addWriter($writer); } } return $log; }
/** * @covers Robo47_Log::log */ public function testLogWithDefaultCategoryFallback() { $log = new Robo47_Log(); $writer = new Robo47_Log_Writer_Mock(); $log->addWriter($writer); $log->setDefaultCategory('default'); $log->log('Foo', 0); $this->assertEquals(1, count($writer->events)); $this->assertArrayHasKey('category', $writer->events[0]); $this->assertEquals('default', $writer->events[0]['category']); }