| Conditions | 7 |
| Paths | 36 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | private function log($level,$msg){ |
||
| 17 | $date = gmdate('D, d M Y H:i:s \G\M\T'); |
||
| 18 | $log = $date." ".$level."\r\n".$msg."\r\n"; |
||
| 19 | if(defined('KS3_API_LOG_PATH') ){ |
||
| 20 | $log_path = KS3_API_LOG_PATH; |
||
| 21 | if(empty($log_path)){ |
||
| 22 | $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR; |
||
| 23 | } |
||
| 24 | }else{ |
||
| 25 | $log_path = KS3_API_PATH.DIRECTORY_SEPARATOR.'log'.DIRECTORY_SEPARATOR; |
||
| 26 | } |
||
| 27 | |||
| 28 | //检测日志目录是否存在 |
||
| 29 | if(!file_exists($log_path)){ |
||
| 30 | mkdir($log_path); |
||
| 31 | } |
||
| 32 | |||
| 33 | $log_name = $log_path.'ks3_php_sdk_'.date('Y-m-d').'.log'; |
||
| 34 | |||
| 35 | if(KS3_API_DISPLAY_LOG){ |
||
| 36 | echo $log; |
||
| 37 | } |
||
| 38 | |||
| 39 | if(KS3_API_LOG){ |
||
| 40 | if(!error_log($log,3,$log_name)){ |
||
| 41 | throw new Ks3ClientException("write to log file error"); |
||
| 42 | } |
||
| 46 | ?> |
||
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.