當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Log::record方法代碼示例

本文整理匯總了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));
 }
開發者ID:Lofanmi,項目名稱:think,代碼行數:7,代碼來源:fileTest.php

示例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;
 }
開發者ID:sayi21cn,項目名稱:corethink,代碼行數:65,代碼來源:AddonModel.class.php

示例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;
 }
開發者ID:Emon0526,項目名稱:zhuoying-wx,代碼行數:40,代碼來源:SmsLogic.class.php

示例4: testRecord

 public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search($record_msg, $logs['notice']));
 }
開發者ID:top-think,項目名稱:framework,代碼行數:7,代碼來源:fileTest.php

示例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];
 }
開發者ID:xuyi5918,項目名稱:ipensoft,代碼行數:32,代碼來源:Lang.php

示例6: testSave

 public function testSave()
 {
     Log::init(['type' => 'test']);
     Log::clear();
     Log::record('test');
     Log::record([1, 2, 3]);
     $this->assertTrue(Log::save());
 }
開發者ID:Lofanmi,項目名稱:think,代碼行數:8,代碼來源:logTest.php

示例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();
     }
 }
開發者ID:GDdark,項目名稱:cici,代碼行數:64,代碼來源:Session.php

示例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;
 }
開發者ID:huzhengchuan,項目名稱:trader,代碼行數:9,代碼來源:ApiController.class.php

示例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);
 }
開發者ID:Emon0526,項目名稱:zhuoying-wx,代碼行數:10,代碼來源:CronController.class.php

示例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');
 }
開發者ID:noikiy,項目名稱:print,代碼行數:61,代碼來源:TokenController.class.php

示例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'));
 }
開發者ID:jackycgq,項目名稱:GreenCMS,代碼行數:12,代碼來源:ApiController.class.php

示例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;
     }
 }
開發者ID:klsf,項目名稱:kldns,代碼行數:20,代碼來源:Error.php

示例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);
 }
開發者ID:xuyi5918,項目名稱:ipensoft,代碼行數:22,代碼來源:Think.php

示例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);
 }
開發者ID:samplecms,項目名稱:framework,代碼行數:22,代碼來源:Think.php

示例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());
 }
開發者ID:zachdary,項目名稱:GreenCMS,代碼行數:23,代碼來源:ThinkWechat.class.php


注:本文中的think\Log::record方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。