本文整理匯總了PHP中vB::getLogger方法的典型用法代碼示例。如果您正苦於以下問題:PHP vB::getLogger方法的具體用法?PHP vB::getLogger怎麽用?PHP vB::getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vB
的用法示例。
在下文中一共展示了vB::getLogger方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __call
public function __call($method, $arguments)
{
try {
$logger = vB::getLogger('api.' . $this->controller . '.' . $method);
//check so that we don't var_export large variables when we don't have to
if ($logger->isInfoEnabled()) {
if (!($ip = vB::getRequest()->getAltIp())) {
$ip = vB::getRequest()->getIpAddress();
}
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller} from ip {$ip} \n\$arguments = " . var_export($arguments, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->info($message);
$logger->info("time: " . microtime(true));
}
if ($logger->isTraceEnabled()) {
$message = str_repeat('=', 80) . "\n " . $this->getTrace() . str_repeat('=', 80) . "\n";
$logger->trace($message);
}
$c = $this->api;
// This is a hack to prevent method parameter reference error. See VBV-5546
$hackedarguments = array();
foreach ($arguments as $k => &$arg) {
$hackedarguments[$k] =& $arg;
}
$return = call_user_func_array(array(&$c, $method), $hackedarguments);
//check so that we don't var_export large variables when we don't have to
if ($logger->isDebugEnabled()) {
$message = str_repeat('=', 80) . "\ncalled {$method} on {$this->controller}\n\$return = " . var_export($return, true) . "\n" . str_repeat('=', 80) . "\n";
$logger->debug($message);
}
return $return;
} catch (vB_Exception_Api $e) {
$errors = $e->get_errors();
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
} catch (vB_Exception_Database $e) {
$config = vB::getConfig();
if (!empty($config['Misc']['debug']) or vB::getUserContext()->hasAdminPermission('cancontrolpanel')) {
$errors = array('Error ' . $e->getMessage());
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
return array('errors' => $errors);
} else {
// This text is purposely hard-coded since we don't have
// access to the database to get a phrase
return array('errors' => array(array('There has been a database error, and the current page cannot be displayed. Site staff have been notified.')));
}
} catch (Exception $e) {
$errors = array(array('unexpected_error', $e->getMessage()));
$config = vB::getConfig();
if (!empty($config['Misc']['debug'])) {
$trace = '## ' . $e->getFile() . '(' . $e->getLine() . ") Exception Thrown \n" . $e->getTraceAsString();
$errors[] = array("exception_trace", $trace);
}
return array('errors' => $errors);
}
}
示例2: assertQuery
public function assertQuery($queryid, $params = array(), $orderby = false)
{
//make sure we have been initialized
if (!isset(self::$instance)) {
return false;
}
if ($this->debugDisplayNextQuerySql) {
$params[vB_dB_Query::DEBUG_QUERY] = 1;
}
// get the query object
$query = vB_dB_Query::getQuery($queryid, $params, self::$db, self::$userinfo, self::$dbtype, self::$dbSlave);
if (isset($params[vB_dB_Query::DEBUG_QUERY])) {
unset($params[vB_dB_Query::DEBUG_QUERY]);
}
if ($this->debugDisplayNextQuerySql) {
$this->debugDisplayNextQuerySql = false;
$query->debugDisplayNextQuerySql();
}
//set the parameters. The children will raise an error if they don't have enough data.
$check = $query->setQuery($params, $orderby);
/**If we are in development mode, record this query **/
if ($this->debug) {
$this->queryCount += 1;
/**for performance measuring- number of queries on this page **/
if (!empty($_REQUEST['querylist'])) {
$displayParams = $params;
unset($displayParams[vB_dB_Query::TYPE_KEY]);
$displayParam = var_export($displayParams, true);
if (strlen($displayParam) > 256) {
$this->queries[] = $queryid . ': ' . substr($displayParam, 0, 256) . '...';
} else {
$this->queries[] = $queryid . ': ' . $displayParam;
}
}
}
if ($this->debugLog) {
$starttime = microtime(true);
//We don't want a full trace.
$stack = array();
$trace = debug_backtrace(false);
foreach ($trace as $key => $step) {
$line = "Step {$key}: in " . $step['function'];
foreach (array('line', 'step', 'file') as $field) {
if (!empty($step[$field])) {
$line .= ' ' . $field . ' ' . $step[$field];
}
}
$stack[] = $line;
}
$info = "---------------------\nQuery: " . $queryid . "\n" . var_export($params, true) . "\n" . implode("\n", $stack) . "\n";
if (isset($params[vB_dB_Query::TYPE_KEY])) {
vB::getLogger("dbAssertor.{$queryid}." . $params[vB_dB_Query::TYPE_KEY])->info($info);
} else {
vB::getLogger("dbAssertor.{$queryid}")->info($info);
}
$result = $query->execSQL();
vB::getLogger("dbAssertor.{$queryid}")->info("time: " . (microtime(true) - $starttime));
return $result;
}
return $query->execSQL();
}