本文整理汇总了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();
}