本文整理匯總了PHP中GlobalConfig::LOGGER_ENABLE方法的典型用法代碼示例。如果您正苦於以下問題:PHP GlobalConfig::LOGGER_ENABLE方法的具體用法?PHP GlobalConfig::LOGGER_ENABLE怎麽用?PHP GlobalConfig::LOGGER_ENABLE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GlobalConfig
的用法示例。
在下文中一共展示了GlobalConfig::LOGGER_ENABLE方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: func
function func(GearmanJob $job)
{
$data = json_decode($job->workload(), true);
// 臨時關閉Logger
$tmpEnable = GlobalConfig::$LOGGER_ENABLE;
GlobalConfig::$LOGGER_ENABLE = false;
LoggerInterface::save($data);
GlobalConfig::$LOGGER_ENABLE = $tmpEnable;
}
示例2: insert
private static function insert($tag, $level, $msg)
{
// 是否需要Logger
if (!GlobalConfig::$LOGGER_ENABLE) {
return;
}
// 臨時關閉Logger
$tmpEnable = GlobalConfig::$LOGGER_ENABLE;
GlobalConfig::$LOGGER_ENABLE = false;
// 校驗tag
$tags = LoggerKeys::$allTags;
if (!in_array($tag, $tags)) {
throw new LibraryException("TAG:{$tag} 需要在LoggerKeys中定義!");
}
// 獲取錯誤信息
if (is_subclass_of($msg, 'Exception')) {
$traceList = $msg->getTrace();
$message = $msg->getMessage();
$traceInfo = $traceList[0];
$loc = $traceInfo['file'] . ':' . $traceInfo['line'];
} else {
$traceList = debug_backtrace();
$message = $msg;
$traceInfo = $traceList[1];
$loc = $traceInfo['file'] . ':' . $traceInfo['line'];
}
$now = time();
$data = array('create_time' => $now, 'update_time' => $now, 'tag' => $tag, 'level' => $level, 'client_ip' => Http::getClientIp(), 'client_port' => Http::getClientPort(), 'server_ip' => Http::getServerIp(), 'server_port' => Http::getServerPort(), 'url' => Url::getCurrentUrl(), 'post' => json_encode($_POST), 'loc' => $loc, 'message' => $message, 'trace' => json_encode($traceList));
if (GlobalConfig::$LOGGER_ASYNC) {
$gearman = GearmanPool::getClient(GearmanConfig::$SERVER_COMMON);
$gearman->doBackground('logger_async', json_encode($data));
} else {
LoggerInterface::save($data);
}
GlobalConfig::$LOGGER_ENABLE = $tmpEnable;
}