public function execute() { //1. check if user is login as needed $arrUserinfo = Saf_SmartMain::getUserInfo(); if (empty($arrUserinfo)) { //ouput error } //2. get and validate input params $arrRequest = Saf_SmartMain::getCgi(); $arrInput = $arrRequest['get']; if (!isset($arrInput['id'])) { //output error } Bd_Log::debug('request input', 0, $arrInput); //3. call PageService $objServicePageSample = new Service_Page_Sample(); $arrPageInfo = $objServicePageSample->execute($arrInput); //4. chage data to out format $arrOutput = $arrPageInfo; //5. build page // smarty模板,以下渲染模板的代码依赖于提供一个tpl模板 //$tpl = Bd_TplFactory::getInstance(); //$tpl->assign($arrOutput); //$tpl->display('en/newapp/index.tpl'); //这里直接输出,作为示例 $strOut = $arrOutput['data']; echo $strOut; //notice日志信息打印,只需要添加日志信息,saf会自动打一条log Bd_Log::addNotice('out', $arrOutput); }
public function actionStartUp() { //启动OMP $objOmp = new Bd_Omp(); $objOmp->start(); $uid = 0; $arrUserInfo = Saf_Action_SessionAction::getUserInfo(); if (is_array($arrUserInfo) && isset($arrUserInfo['uid'])) { $uid = intval($arrUserInfo['uid']); } //uid字段是omp字段,wf和notice日志都需要打印 Bd_Log::addNotice('uid', $uid); Saf_Action_PublicAction::setPublic(array('omp' => $objOmp)); }
public function setObject($file_name, $object_name, $private = true) { $file_name = strpos($file_name, '@') !== false ? $file_name : '@' . $file_name; $post_data = array('upload' => $file_name); $signature = $this->getSignature($object_name); // object_name需要透传 $baseUrl = self::HOST . '/' . self::BUCKET . '/' . $object_name . '?sign=' . self::FLAG . ':' . self::ACCESS_KEY . ':' . $signature; $url = $baseUrl . '&dumpheader=1&disposition=attach'; if ($private === false) { $headers = array(); $headers[] = "x-bs-acl:public-read"; $headers[] = "image/png"; } $res = Net_Util::postData($url, $post_data, $headers); // POST if (!empty($res)) { $ret = json_decode($res, true); if (empty($ret)) { Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Invaid Json String] Return[%s]", $res)); return false; } try { if ($ret["Error"]["Code"] === 0) { return true; } else { Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Get error from BCS] Return[%s]", $res)); return false; } } catch (Exception $e) { Bd_Log::addNotice(__CLASS__, sprintf("Notice[bcs] Message[Catch an exception] Return[%s]", $res)); return false; } } else { return false; } }
/** * @brief 数据访问接口初始化,须在语言识别(checkLocale)之后调用 or $param * @param $param * 1) 默认不传,使用识别后的instance,locale; * 2) array('instance' => xx, //必须 * 'locale' => xx //必须 * ) * @return bool */ public function initDataInterface($param = null) { if (null == $param) { $instance = Bd_Global::getInstance(); $locale = Bd_Global::getLocale(); } else { $instance = $param['instance']; $locale = $param['locale']; if (empty($param['instance'])) { Bd_Log::warning(" initDataInterface input param \"instance\" can't be empty! param:" . var_export($param, true)); return false; } } if (empty($instance)) { Bd_Log::warning(" initDataInterface \"instance\" can't be empty! "); return false; } Bd_Conf::setLevel("/i18n/instance/{$instance}/"); if (!class_exists('Bd_RalRpc')) { require_once dirname(__FILE__) . '/RalRpc.php'; } require_once dirname(__FILE__) . '/global/strategy/Base.php'; Bd_RalRpc::add_extra(array('instance' => $instance, 'region' => $instance, 'locale' => $locale)); Bd_Log::addNotice('instance', $instance); Bd_Log::addNotice('locale', $locale); Bd_Log::addNotice('strategy', self::$_cur_strategy); return true; }
private function addOmpLog() { $tmp = gettimeofday(); $optime = $tmp['sec'] . '.' . intval($tmp['usec'] / 1000); Bd_Log::addNotice('optime', $optime); Bd_Log::addNotice('client_ip', Bd_Ip::getClientIp()); Bd_Log::addNotice('local_ip', Bd_Ip::getLocalIp()); Bd_Log::addNotice('product', defined('PRODUCT') ? PRODUCT : 'ORP'); Bd_Log::addNotice('subsys', defined('SUBSYS') ? SUBSYS : 'ORP'); Bd_Log::addNotice('module', defined('MODULE') ? MODULE : 'ORP'); Bd_Log::addNotice('uniqid', defined('UNIQID') ? UNIQID : 0); $cgId = function_exists('ral_get_cgid') ? ral_get_cgid() : 0; Bd_Log::addNotice('cgid', $cgId); }
/** * 追到notice的LOG数据 * @author cuichao02 * @date 2011/02/21 **/ public static function addLogNotice($arrArgs) { foreach ($arrArgs as $k => $v) { Bd_Log::addNotice($k, $v); } }