本文整理匯總了PHP中log::setAlternativeWrite方法的典型用法代碼示例。如果您正苦於以下問題:PHP log::setAlternativeWrite方法的具體用法?PHP log::setAlternativeWrite怎麽用?PHP log::setAlternativeWrite使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類log
的用法示例。
在下文中一共展示了log::setAlternativeWrite方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
private function __construct($src, $debug, $request)
{
$this->_db = new DB('master');
$this->_action = $src;
$this->_request = $request;
foreach ($this->_request as $k => $v) {
switch ($k) {
case 'userid':
case 'nickname':
case 'paymentid':
case 'paymode':
$v = __paramValue('int', $v);
break;
case 'amount':
$v = __paramValue('money', $v);
break;
default:
$v = __paramValue('string', $v);
}
$this->_request[$k] = $v;
}
// if ($debug) {
$this->_log = new log('onlinedengi/income-%d%m%Y.log', 'a', '%d.%m.%Y %H:%M:%S : ' . self::$req_descr[$this->_action] . ' : ');
$this->_log->addAlternativeMethodSave(new log_pskb(), true);
$alt_out = array('param' => self::$req_descr[$this->_action], 'response' => $this->_request);
$this->_log->setAlternativeWrite(serialize($alt_out), 'log_pskb');
// $dbg = var_export($this->_request, true);
$this->_log->writevar($this->_request);
// }
}
示例2: _request
protected function _request($method, $params, $content_plain = false, $query_params = array('method' => 'POST'))
{
$ch = curl_init();
$str_method = strtolower($method);
$cp1251_params = $params;
if (is_array($params)) {
foreach ($params as $k => $v) {
$params[$k] = $this->_enc($v);
}
} else {
$params = $this->_enc($params);
}
if ($query_params['method'] == 'GET') {
$method .= (defined('PSKB_TEST_MODE') ? "&" : "?") . http_build_query($params);
}
if (defined('PSKB_BETA_MODE')) {
curl_setopt($ch, CURLOPT_PORT, 8085);
curl_setopt($ch, CURLOPT_URL, "http://localhost/apiLCPlace/" . $method);
} else {
if (!defined('PSKB_TEST_MODE')) {
curl_setopt($ch, CURLOPT_PORT, 8085);
curl_setopt($ch, CURLOPT_URL, 'http://192.168.88.13/apiLCPlace/' . $method);
// curl_setopt($ch, CURLOPT_URL, "http://localhost/apiLCPlace/" . $method);
} else {
if (defined('BASIC_AUTH')) {
curl_setopt($ch, CURLOPT_USERPWD, BASIC_AUTH);
}
curl_setopt($ch, CURLOPT_URL, $this->_request_url . $method);
}
}
if ($query_params['method'] == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
if ($content_plain) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));
}
$res = curl_exec($ch);
$log = new log("pskb/{$str_method}-" . SERVER . '-%d%m%Y.log', 'a', '%d.%m.%Y %H:%M:%S : ');
if ($this->_useAlternativeLog) {
$log->addAlternativeMethodSave(new log_pskb(), true);
$alt_out = array('request_url' => $this->_request_url . $method, 'param' => $cp1251_params, 'response' => iconv('utf8', 'cp1251', $res));
$log->setAlternativeWrite(serialize($alt_out), 'log_pskb');
}
ob_start();
var_dump($this->_request_url . $method);
var_dump($params);
var_dump($res);
$out = ob_get_clean();
$log->writeln(iconv('utf8', 'cp1251', $out));
return $res;
}