本文整理匯總了PHP中think\Log::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Log::save方法的具體用法?PHP Log::save怎麽用?PHP Log::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類think\Log
的用法示例。
在下文中一共展示了Log::save方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSave
public function testSave()
{
Log::init(['type' => 'test']);
Log::clear();
Log::record('test');
Log::record([1, 2, 3]);
$this->assertTrue(Log::save());
}
示例2: appShutdown
/**
* Shutdown Handler
*/
public static function appShutdown()
{
if (!is_null($error = error_get_last()) && self::isFatal($error['type'])) {
// 將錯誤信息托管至think\ErrorException
$exception = new ErrorException($error['type'], $error['message'], $error['file'], $error['line']);
self::appException($exception);
}
// 寫入日誌
Log::save();
}
示例3: appShutdown
/**
* Shutdown Handler
* @return bool true-禁止往下傳播已處理過的異常; false-未處理的異常繼續傳播
*/
public static function appShutdown()
{
// 寫入日誌
Log::save();
if ($error = error_get_last()) {
// 將錯誤信息托管至think\ErrorException
$exception = new ErrorException($error['type'], $error['message'], $error['file'], $error['line']);
/**
* Shutdown handler 中的異常將不被往下傳播
* 所以,這裏我們必須手動傳播而不能像 Error handler 中那樣 throw
*/
self::appException($exception);
// 禁止往下傳播已處理過的異常
return true;
}
return false;
}
示例4: logDebug
public function logDebug($message)
{
Log::write($message, 'DEBUG');
Log::save();
}
示例5: LoggerPrint
protected function LoggerPrint($message, $level = 'ERROR')
{
Log::write($message, $level);
Log::save();
}
示例6: mtReturn
public function mtReturn($status, $info, $navTabId = '', $callbackType = 'closeCurrent', $forwardUrl = '', $rel = '', $type = '')
{
// 保證AJAX返回後也能保存日誌
if (C('LOG_RECORD')) {
\Think\Log::save();
}
$result = array();
if ($navTabId == '') {
$navTabId = $_REQUEST['navTabId'];
}
if ($status == '200') {
$this->sysLogs('', $info);
}
if ($status == '201') {
$status = 200;
}
$result['statusCode'] = $status;
// dwzjs
$result['navTabId'] = $navTabId;
// dwzjs
$result['callbackType'] = $callbackType;
// dwzjs
$result['message'] = $info;
// dwzjs
$result['forwardUrl'] = $forwardUrl;
$result['rel'] = $rel;
if (empty($type)) {
$type = C('DEFAULT_AJAX_RETURN');
}
if (strtoupper($type) == 'JSON') {
// 返回JSON數據格式到客戶端 包含狀態信息
header("Content-Type:text/html; charset=utf-8");
exit(json_encode($result));
} elseif (strtoupper($type) == 'XML') {
// 返回xml格式數據
header("Content-Type:text/xml; charset=utf-8");
exit(xml_encode($result));
} elseif (strtoupper($type) == 'EVAL') {
// 返回可執行的js腳本
header("Content-Type:text/html; charset=utf-8");
exit($data);
} else {
// TODO 增加其它格式
}
}
示例7: login
/**
* 登錄
*/
public function login()
{
$User = D("User");
// 實例化User對象
$userData = null;
if (I("token") != null) {
$User->validation(array(array('token', 'require', '令牌不能為空', Model::MUST_VALIDATE, 'regex'), array('token', '10,50', '令牌長度不正確', Model::MUST_VALIDATE, 'length')));
$userData = $User->relation('privacy')->where("id = (select uid from t_thirdaccount where token = '%s')", I("token"))->field("id,token")->find();
if (empty($userData)) {
$this->retError(403, '沒有對應的token');
}
} else {
$User->validation(array(array('phonenumber', 'require', '手機號不能為空', Model::MUST_VALIDATE, 'regex'), array('password', 'require', '密碼不能為空', Model::MUST_VALIDATE, 'regex'), array('password', '6,50', '密碼長度不正確', Model::MUST_VALIDATE, 'length'), array('phonenumber', 'phonenumber', '手機號格式不正確', Model::MUST_VALIDATE, 'regex')));
\Think\Log::record(I("phonenumber"));
\Think\Log::record(md5(I('password')));
\Think\Log::save();
setLog(I("phonenumber"));
$userData = $User->where("phonenumber='%s' and password = '%s'", I("phonenumber"), md5(I('password')))->field("id,token")->find();
if (empty($userData)) {
$this->retError(201, "帳號或密碼錯誤");
}
}
$this->retSuccess($userData);
}
示例8: LogService
define('APP_PATH', './Yoga/');
// define('DIR_SECURE_FILENAME', 'default.html');
// define('BUILD_DIR_SECURE', false);
// define('BIND_MODULE', 'Channelmanager');
// define('BIND_CONTROLLER','Ptmanager');
// define('BUILD_CONTROLLER_LIST','Index,User,Brand');
define('RUNTIME_PATH', './Runtime/');
// define('STORAGE_TYPE','sae');
// define('APP_MODE','sae');//application mode
// //默認錯誤跳轉對應的模板文件
// 'TMPL_ACTION_ERROR' => THINK_PATH . 'Tpl/dispatch_jump.tpl',
// //默認成功跳轉對應的模板文件
// 'TMPL_ACTION_SUCCESS' => THINK_PATH . 'Tpl/dispatch_jump.tpl',
define('APP_STATUS', 'office');
// will load the status config file./application/Common/COnf/home.php
define('BUILD_LITE_FILE', true);
require "./LogService.class.php";
$ll = new LogService("request", "request");
$url = $_SERVER["REQUEST_URI"];
if ($url != "/Home/Task/checkTask") {
$ll->debug($_SERVER["REQUEST_URI"]);
if (!empty($_POST)) {
$ll->debug($_POST);
}
if (!empty($_GET)) {
$ll->debug($_GET);
}
}
require './Framework/Core.php';
\Think\Log::save();
示例9: returnMessage
function returnMessage($code, $msg, $ext = array())
{
$success = $code == 200;
$message = $ext;
$message['status'] = $success ? 'true' : 'false';
// 返回JSON數據格式到客戶端 包含狀態信息
header('Content-Type:application/json; charset=utf-8');
// 跨域 add 20150416 By NanQi
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Headers: X-Requested-With');
if ($success) {
$httpStatus = 200;
$message['data'] = empty($msg) && !is_array($msg) ? '操作成功' : $msg;
} else {
//$message['errcode'] = $code;
$message['errcode'] = empty($msg) ? '操作失敗' : $msg;
$status = substr($code, 0, 1);
switch ($status) {
case 2:
$httpStatus = 201;
break;
case 3:
$httpStatus = 202;
break;
case 4:
$httpStatus = 203;
break;
case 5:
\Think\Log::record('[' . $code . ']' . $msg);
$httpStatus = 500;
break;
case 7:
\Think\Log::record('[' . $code . ']' . $msg);
$httpStatus = 501;
break;
case 9:
\Think\Log::record('[' . $code . ']' . $msg);
$httpStatus = 502;
break;
}
}
// 發送HTTP狀態碼
send_http_status($httpStatus);
G('request-end');
$requertTime = G('initTime', 'request-end', 6);
if ($requertTime > 0.3) {
\Think\Log::record('[request-time] ' . $requertTime . 's');
\Think\Log::record('[request-memory] ' . G('initTime', 'request-end', 'm') . 'kb');
}
\Think\Log::record('[Response] ' . $httpStatus);
\Think\Log::save();
exit(json_encode($message, 0));
}
示例10: sae_log
function sae_log($key, $log)
{
\Think\Log::record($key . ':' . $log);
\Think\Log::save();
}