本文整理汇总了PHP中OC_Request::getRequestID方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Request::getRequestID方法的具体用法?PHP OC_Request::getRequestID怎么用?PHP OC_Request::getRequestID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Request
的用法示例。
在下文中一共展示了OC_Request::getRequestID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* write a message in the log
* @param string $app
* @param string $message
* @param int $level
*/
public static function write($app, $message, $level)
{
$minLevel = min(OC_Config::getValue("loglevel", OC_Log::WARN), OC_Log::ERROR);
if ($level >= $minLevel) {
// default to ISO8601
$format = OC_Config::getValue('logdateformat', 'c');
$logtimezone = OC_Config::getValue("logtimezone", 'UTC');
try {
$timezone = new DateTimeZone($logtimezone);
} catch (Exception $e) {
$timezone = new DateTimeZone('UTC');
}
$time = new DateTime(null, $timezone);
$reqId = \OC_Request::getRequestID();
$remoteAddr = \OC_Request::getRemoteAddress();
// remove username/passwords from URLs before writing the to the log file
$time = $time->format($format);
if ($minLevel == OC_Log::DEBUG) {
$url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '--';
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '--';
$entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time', 'method', 'url');
} else {
$entry = compact('reqId', 'remoteAddr', 'app', 'message', 'level', 'time');
}
$entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
@chmod(self::$logFile, 0640);
if ($handle) {
fwrite($handle, $entry . "\n");
fclose($handle);
} else {
// Fall back to error_log
error_log($entry);
}
}
}
示例2: printExceptionErrorPage
/**
* print error page using Exception details
* @param Exception $exception
*/
public static function printExceptionErrorPage(Exception $exception)
{
$content = new \OC_Template('', 'exception', 'error', false);
$content->assign('errorMsg', $exception->getMessage());
$content->assign('errorCode', $exception->getCode());
$content->assign('file', $exception->getFile());
$content->assign('line', $exception->getLine());
$content->assign('trace', $exception->getTraceAsString());
$content->assign('debugMode', defined('DEBUG') && DEBUG === true);
$content->assign('remoteAddr', OC_Request::getRemoteAddress());
$content->assign('requestID', OC_Request::getRequestID());
$content->printPage();
die;
}