123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- $GLOBALS['API_TEST'] = true;
- /**
- * Description of Log
- *
- * @author jgao
- */
- class Log {
- //put your code here
-
- static function dtCurrent(){
- return date('Y-m-d ').(date('H') + 8).date(':i:s');
- }
-
- /**
- * 浏览器打印调试信息
- * @param type $msg
- */
- static function debug($msg){
- if($GLOBALS['API_TEST']){
- echo('['.self::dtCurrent().']|'.$msg.'</br>');
- }
- }
- /**
- * 浏览器输出对象信息
- * @param type $obj
- */
- static function console($obj){
- self::debug(json_encode($obj));
- }
-
- /**
- * 浏览器弹窗提示
- * @param type $msg
- */
- static function alert($msg){
- if($GLOBALS['API_TEST']){
- echo "<Script language=\"javascript\">alert(\"".$msg."\");</Script>";
- }
- }
-
- /**
- * 写日志文件
- * 注意:这里必须写入CEE指定的日志目录!!
- * Ps.CEE 目录: dirname(__FILE__)."/../../../../logs/".date("Ynj").".log";
- * @param type $msg
- */
- static function output($msg){
- $fileName = "";
- if(GAME_ONLINE){
- $fileName = dirname(__FILE__)."/../../../../logs/".date("Ynj").".log"; //cee目录
- }else{
- $fileName = dirname(__FILE__)."/../AppLog/".date("Ynj").".log";
- }
- $fd = fopen($fileName,"a+");
- fputs($fd,"[".self::dtCurrent()."]|".json_encode($msg)."\r\n");
- fclose($fd);
- }
- }
|