最近的项目使用了 阿里云的日志服务,感觉挺好用,SDK接入照着官方sdk里面的DEMO,简单顺利接入。核心代码就个函数。
private function getObj($topic='TestTopic'){
//通过使用相同参数调用工厂方法来创建相同的记录器实例
return \Aliyun_Log_LoggerFactory::getLogger(self::$client, $this->project, $this->logstore,env('APP_ENV','dev').'_'.$topic);
}
public function install_log($logMap,$topics,$auto=0){
$anotherLogger = $this->getObj($topics);
switch ($logMap['logLevel']){
case 'info':
$anotherLogger->infoArray($logMap);
break;
case 'debug':
$anotherLogger->debugArray($logMap);
break;
case 'warn':
$anotherLogger->warnArray($logMap);
break;
case 'error':
$anotherLogger->errorAr