getConstants(); if($code) return isset($stants[$code]) ? $stants[$code] : ''; else return $stants; } /* * 错误日志记录 * * */ public static function recodeErrorLog(Exception $exception) { $data=[ 'code'=>$exception->getCode(), 'msg'=>$exception->getMessage(), 'file'=>$exception->getFile(), 'line'=>$exception->getLine(), ]; $log="[{$data['code']}] {$data['msg']} [{$data['file']} : {$data['line']}]"; self::writeLog($log,'e'); } /* * 记录日志 * $param string $contentlog 日志内容 * $param string $typeLog 日志类型 * $param string $dirLog 日志目录 * */ public static function writeLog($contentlog='',$typeLog='',$dirLog='ebapi') { Log::init([ 'type' => 'File', 'path' => LOG_PATH.($dirLog ? $dirLog.'/' : '') ]); if($contentlog==='') $contentlog=self::$logInfo; if($contentlog===null) return false; if(is_array($contentlog)) $contentlog=var_export($contentlog,true); if(is_object($contentlog)) $contentlog=var_export($contentlog,true); switch (strtoupper($typeLog)){ case 'SQL':case 'S': Log::sql($contentlog); break; case 'ERROR':case 'E': Log::error($contentlog); break; case 'INFO':case 'I': Log::info($contentlog); break; case 'NOTICE':case 'N': Log::notice($contentlog); break; case 'ALERT':case 'A': Log::alert($contentlog); break; case 'LOG':case 'L': Log::log($contentlog); break; } } }