/** * 各个对象初始化 * * @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_alert_works_fine() { Alert::init(__DIR__ . '/ini/alert.ini'); ob_start(); Alert::push('test', Alert::URGENCE); $this->assertContains(' [dev] test', ob_get_contents()); @ob_end_clean(); }
/** * 执行函数 * * @access public * @return Boolean true or false : next loop ? */ public function execute($loop = true) { $status = array_filter(self::queque_status_monitor()); if (!empty($status)) { Alert::push(sprintf('queque_status: (%s)', json_encode($status)), Alert::NORMAL | Alert::URGENCE); } $status = self::import_consist_monitor(); if (!empty($status)) { Alert::push(sprintf('import_consist: (%s)', json_encode($status)), Alert::NORMAL | Alert::URGENCE); } return $loop; }