/** * 各个对象初始化 * * @access public static * @return void */ public static function init($ini) { self::setAutoLoad(); /** * @配置文件 */ \Myfox\Lib\Config::register('default', $ini); $config = \Myfox\Lib\Config::instance('default'); /** * @数据库 */ foreach ((array) $config->get('mysql') as $name => $file) { \Myfox\Lib\Mysql::register($name, $file); } /** * @日志对象 */ foreach ((array) $config->get('log') as $name => $url) { \Myfox\Lib\Factory::registerLog($name, $url); } /** * @告警提醒 */ \Myfox\Lib\Alert::init(__DIR__ . '/../etc/alert.ini'); }
public function test_should_factory_get_log_works_fine() { $log = Factory::getLog('Iamnotexist'); $this->assertTrue($log instanceof \Myfox\Lib\Blackhole); Factory::registerLog('unittest', sprintf('log://debug.notice.warning.error/%s/tmp/test.log?buffer=0', __DIR__)); $log = Factory::getLog('UnittEst '); $this->assertTrue($log instanceof \Myfox\Lib\Log); }