本文整理汇总了PHP中think\Log::record方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::record方法的具体用法?PHP Log::record怎么用?PHP Log::record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类think\Log
的用法示例。
在下文中一共展示了Log::record方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRecord
public function testRecord()
{
$record_msg = 'record';
Log::record($record_msg, 'notice');
$logs = Log::getLog();
$this->assertNotFalse(array_search(['type' => 'notice', 'msg' => $record_msg], $logs));
}
示例2: getAllAddon
/**
* 获取插件列表
* @param string $addon_dir
* @author jry <598821125@qq.com>
*/
public function getAllAddon($addon_dir = THINK_ADDON_PATH)
{
$dirs = array_map('basename', glob($addon_dir . '*', GLOB_ONLYDIR));
if ($dirs === FALSE || !file_exists($addon_dir)) {
$this->error = '插件目录不可读或者不存在';
return FALSE;
}
$addons = array();
$map['name'] = array('in', $dirs);
$list = $this->where($map)->field(true)->order('sort asc,id desc')->select();
foreach ($list as $addon) {
$addons[$addon['name']] = $addon;
}
foreach ($dirs as $value) {
if (!isset($addons[$value])) {
$class = get_addon_class($value);
if (!class_exists($class)) {
// 实例化插件失败忽略执行
\Think\Log::record('插件' . $value . '的入口文件不存在!');
continue;
}
$obj = new $class();
$addons[$value] = $obj->info;
if ($addons[$value]) {
$addons[$value]['status'] = -1;
//未安装
}
}
}
foreach ($addons as &$val) {
switch ($val['status']) {
case '-1':
//未安装
$val['status'] = '<i class="glyphicon glyphicon-trash" style="color:red"></i>';
$val['right_button'] = '<a class="ajax-get" href="' . U('install?addon_name=' . $val['name']) . '">安装</a>';
break;
case '0':
//禁用
$val['status'] = '<i class="glyphicon glyphicon-ban-circle" style="color:red"></i>';
$val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'resume', 'ids' => $val['id'])) . '">启用</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
if ($val['adminlist']) {
$val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
}
break;
case '1':
//正常
$val['status'] = '<i class="glyphicon glyphicon-ok" style="color:green"></i>';
$val['right_button'] = '<a href="' . U('config', array('id' => $val['id'])) . '">设置</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('setStatus', array('status' => 'forbid', 'ids' => $val['id'])) . '">禁用</a> ';
$val['right_button'] .= '<a class="ajax-get" href="' . U('uninstall?id=' . $val['id']) . '">卸载</a> ';
if ($val['adminlist']) {
$val['right_button'] .= '<a href="' . U('adminlist', array('name' => $val['name'])) . '">管理</a>';
}
break;
}
}
return $addons;
}
示例3: sendTemplateSMS
/**
* 发送模板短信
* @param String $to 短信接收彿手机号码集合,用英文逗号分开
* @param array $datas 内容数据 格式为数组 例如:array('Marry','Alon'),如不需替换请填 null
* @param int $tempId 模板Id,测试应用和未上线应用使用测试模板请填写1,正式应用上线后填写已申请审核通过的模板ID
* @return 内容数据|mixed
*/
function sendTemplateSMS($to, $datas, $tempId)
{
$this->Batch = date("YmdHis");
// 拼接请求包体
$data = "";
for ($i = 0; $i < count($datas); $i++) {
$data = $data . "'" . $datas[$i] . "',";
}
$body = "{'to':'{$to}','templateId':'{$tempId}','appId':'{$this->AppId}','datas':[" . $data . "]}";
$level = Log::INFO;
Log::record("response body = " . $body, $level);
// 大写的sig参数
$sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
// 生成请求URL
$url = "https://{$this->ServerIP}:{$this->ServerPort}/{$this->SoftVersion}/Accounts/{$this->AccountSid}/SMS/TemplateSMS?sig={$sig}";
Log::record("request url = " . $url, $level);
// 生成授权:主帐户Id + 英文冒号 + 时间戳。
$authen = base64_encode($this->AccountSid . ":" . $this->Batch);
// 生成包头
$header = array("Accept:application/{$this->BodyType}", "Content-Type:application/{$this->BodyType};charset=utf-8", "Authorization:{$authen}");
// 发送请求
$result = $this->curl_post($url, $body, $header);
Log::record("response body = " . $result, $level);
$datas = json_decode($result);
//重新装填数据
if ($datas->statusCode == 0) {
if ($this->BodyType == "json") {
$datas->TemplateSMS = $datas->templateSMS;
unset($datas->templateSMS);
}
}
return $datas;
}
示例4: testRecord
public function testRecord()
{
$record_msg = 'record';
Log::record($record_msg, 'notice');
$logs = Log::getLog();
$this->assertNotFalse(array_search($record_msg, $logs['notice']));
}
示例5: load
/**
* 加载语言定义(不区分大小写)
* @param string $file 语言文件
* @param string $range 语言作用域
* @return mixed
*/
public static function load($file, $range = '')
{
$range = $range ?: self::$range;
if (!isset(self::$lang[$range])) {
self::$lang[$range] = [];
}
// 批量定义
if (is_string($file)) {
$file = [$file];
}
$lang = [];
foreach ($file as $_file) {
if (is_file($_file)) {
// 记录加载信息
APP_DEBUG && Log::record('[ LANG ] ' . $_file, 'info');
$_lang = (include $_file);
} else {
$_lang = [];
}
$lang = array_change_key_case($_lang) + $lang;
}
if (!empty($lang)) {
self::$lang[$range] = $lang + self::$lang[$range];
}
return self::$lang[$range];
}
示例6: testSave
public function testSave()
{
Log::init(['type' => 'test']);
Log::clear();
Log::record('test');
Log::record([1, 2, 3]);
$this->assertTrue(Log::save());
}
示例7: init
/**
* session初始化
* @param array $config
* @return void
* @throws \think\Exception
*/
public static function init(array $config = [])
{
if (empty($config)) {
$config = Config::get('session');
}
// 记录初始化信息
App::$debug && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
$isDoStart = false;
if (isset($config['use_trans_sid'])) {
ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
}
// 启动session
if (!empty($config['auto_start']) && PHP_SESSION_ACTIVE != session_status()) {
ini_set('session.auto_start', 0);
$isDoStart = true;
}
if (isset($config['prefix'])) {
self::$prefix = $config['prefix'];
}
if (isset($config['var_session_id']) && isset($_REQUEST[$config['var_session_id']])) {
session_id($_REQUEST[$config['var_session_id']]);
} elseif (isset($config['id']) && !empty($config['id'])) {
session_id($config['id']);
}
if (isset($config['name'])) {
session_name($config['name']);
}
if (isset($config['path'])) {
session_save_path($config['path']);
}
if (isset($config['domain'])) {
ini_set('session.cookie_domain', $config['domain']);
}
if (isset($config['expire'])) {
ini_set('session.gc_maxlifetime', $config['expire']);
ini_set('session.cookie_lifetime', $config['expire']);
}
if (isset($config['use_cookies'])) {
ini_set('session.use_cookies', $config['use_cookies'] ? 1 : 0);
}
if (isset($config['cache_limiter'])) {
session_cache_limiter($config['cache_limiter']);
}
if (isset($config['cache_expire'])) {
session_cache_expire($config['cache_expire']);
}
if (!empty($config['type'])) {
// 读取session驱动
$class = false !== strpos($config['type'], '\\') ? $config['type'] : '\\think\\session\\driver\\' . ucwords($config['type']);
// 检查驱动类
if (!class_exists($class) || !session_set_save_handler(new $class($config))) {
throw new ClassNotFoundException('error session handler:' . $class, $class);
}
}
if ($isDoStart) {
session_start();
}
}
示例8: auth
public function auth()
{
$account = I("post.account");
$pwd = I("post.password");
Log::record($account . "" . $pwd);
$all = '{"data":{"account":"947742853@qq.com","apiKey":"ed8b72515a1577c26edebf2f2654238d74108b6d","articleVisible":1,"authString":"0,947742853@qq.com,1439045570","brokerDomain":null,"bwTenant":null,"device":null,"email":"947742853@qq.com","expiredAt":1443862842,"guest":false,"ip":"222.41.113.210","locale":"zh","login":null,"mt4Group":null,"nickname":"test123","phone":null,"randomKey":null,"serviceId":null,"symbols":null,"tenantId":"0","tenantName":null,"token":"1439112842,266,24e8bc0ef5","twTimeout":30,"userAvatar":"https://p-picture.b0.upaiyun.com/default_avatar.jpg","userId":266,"verification":null},"message":"登录成功","result":1}';
$data = json_decode($all);
echo $all;
}
示例9: movieStart
function movieStart($movietime)
{
\Think\Log::record('开场提示:' . $movietime['pid'] . '-' . $movietime['title']);
//推送开场提醒
D('JPush', 'Logic')->pushNotificationByTags(C('PUSH_PARTY_PREFIX') . $movietime['pid'], '你参加的' . $movietime['title'] . '活动即将开始,摇一摇加入社交圈,开启捉影之旅。', null, array("redirect" => "circleentry"));
//向融云服务器发送创建群组的请求
$im = D('Im', 'Logic');
$im->createCircle($movietime['id']);
M('Socialcircle')->where('id = %d', $movietime['id'])->setField('openstatus', 1);
}
示例10: index
/**
*index
*api令牌生成
* 支持操作post
*@return json,xml
*@author NewFuture
*/
public function index()
{
$pwd = I('post.pwd');
$type = I('post.type', null, 'int');
$Model = null;
switch ($type) {
case C('STUDENT'):
case C('STUDENT_API'):
$account = I('post.account', 0, C('REGEX_NUMBER'));
$Model = M('user');
$where['student_number'] = $account;
break;
case C('PRINTER'):
case C('PRINTER_WEB'):
$account = I('post.account', null, C('REGEX_ACCOUNT'));
$Model = M('printer');
$where['account'] = $account;
break;
default:
$data['err'] = 'unknown user type';
}
if (!isset($data)) {
if ($account) {
$key = 'api_' . $account;
$times = S($key);
if ($times > C('MAX_TRIES')) {
\Think\Log::record('api爆破警告:ip:' . get_client_ip() . ',account:' . $account, 'NOTIC', true);
$data['err'] = '此账号尝试次数过多,已经暂时封禁,请于一小时后重试!(ps:你的行为已被系统记录)';
} else {
S($key, $times + 1, 3600);
$info = $Model->where($where)->field('id,password,name')->find();
$id = $info['id'];
$password = $info['password'];
if ($password == encode($pwd, $account)) {
$token = update_token($id, $type);
if ($token) {
S($key, null);
$data['token'] = $token;
$data['name'] = $info['name'];
$data['id'] = $info['id'];
} else {
$data['err'] = '创建令牌失败';
}
} else {
$data['err'] = 'authored failed';
}
}
} else {
$data['err'] == 'illegal account';
}
}
$data['version'] = C('API_VERSION');
$this->response($data, $this->_type == 'xml' ? 'xml' : 'json');
}
示例11: index
public function index()
{
Log::record('收到消息' . date('Ymd H:m:s') . 'Form:' . get_client_ip());
$weixin = new ThinkWechat(get_opinion('weixin_token'));
/* 获取请求信息 */
$data = $weixin->request();
/* 获取回复信息 */
list($content, $type) = $this->reply($data);
/* 响应当前请求 */
$weixin->response($content, $type);
Log::record('发送消息' . date('Ymd H:m:s'));
}
示例12: appError
/**
* Error Handler
* @param integer $errno 错误编号
* @param integer $errstr 详细错误信息
* @param string $errfile 出错的文件
* @param integer $errline 出错行号
* @return bool true-禁止往下传播已处理过的异常
*/
public static function appError($errno, $errstr, $errfile = null, $errline = 0, array $errcontext = [])
{
if ($errno & Config::get('exception_ignore_type')) {
// 忽略的异常记录到日志
Log::record("[{$errno}]{$errstr}[{$errfile}:{$errline}]", 'notice');
} else {
// 将错误信息托管至 think\exception\ErrorException
throw new ErrorException($errno, $errstr, $errfile, $errline, $errcontext);
// 禁止往下传播已处理过的异常
return true;
}
}
示例13: fetch
/**
* 渲染模板文件
* @access public
* @param string $template 模板文件
* @param array $data 模板变量
* @param array $config 模板参数
* @return void
*/
public function fetch($template, $data = [], $config = [])
{
if (!is_file($template)) {
// 获取模板文件名
$template = $this->parseTemplate($template);
}
// 模板不存在 抛出异常
if (!is_file($template)) {
throw new Exception('template file not exists:' . $template, 10700);
}
// 记录视图信息
APP_DEBUG && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
$this->template->fetch($template, $data, $config);
}
示例14: fetch
/**
* 渲染模板文件
* @access public
* @param string $template 模板文件
* @param array $data 模板变量
* @param array $config 模板参数
* @return void
*/
public function fetch($template, $data = [], $config = [])
{
if ('' == pathinfo($template, PATHINFO_EXTENSION)) {
// 获取模板文件名
$template = $this->parseTemplate($template);
}
// 模板不存在 抛出异常
if (!is_file($template)) {
throw new TemplateNotFoundException('template not exists:' . $template, $template);
}
// 记录视图信息
App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
$this->template->fetch($template, $data, $config);
}
示例15: response
/**
* * 响应微信发送的信息(自动回复)
* @param array $content 回复信息,文本信息为string类型
* @param string $type 消息类型
* @param int|string $flag 是否新标刚接受到的信息
* @internal param string $to 接收用户名
* @internal param string $from 发送者用户名
* @return string XML字符串
*/
public function response($content, $type = 'text', $flag = 0)
{
/* 基础数据 */
$this->data = array('ToUserName' => $this->data['FromUserName'], 'FromUserName' => $this->data['ToUserName'], 'CreateTime' => NOW_TIME, 'MsgType' => $type);
/* 添加类型数据 */
$this->{$type}($content);
/* 添加状态 */
$this->data['FuncFlag'] = $flag;
/* 转换数据为XML */
$xml = new \SimpleXMLElement('<xml></xml>');
$this->data2xml($xml, $this->data);
\Think\Log::record('echo:' . $xml->asXML());
exit($xml->asXML());
}