m_strDirRoot = strLogBaseDir . "\\ServerLog\\" . \CommFunc\GetMonth() . "\\"; } else { $this->m_strDirRoot = $strRootDir; } #构造日志对象和数组 $this->m_arrayLog = array(); $this->AddLogObj($strFileDir, $strFileName, $strExtraInfo, $writeMode); } #增加log对象 public function AddLogObj($strFileDir, $strFileName, $strExtraInfo = '', $writeMode = \Log4Me\DEF_WRITE_MODE) { #获得任意一个日志对象,取得它的扩展输出内容 if (count($this->m_arrayLog)) { foreach ($this->m_arrayLog as $log) { $strExtraInfo = $log->GetAffixStr() . " " . $strExtraInfo; break; } } foreach ($this->m_arrayLog as $log) { $log->SetAffixStr($strExtraInfo); } if (bNewStyleLogging) { $strPhpDir = $this->m_strDirRoot . self::strLogDir . "\\" . date("d", time()) . '\\' . $strFileDir; } else { $strPhpDir = $this->m_strDirRoot . self::strLogDir . '\\' . $strFileDir; } $logPhpFile = new \Log4Me\Log4Me($strPhpDir, $strFileName, \Log4Me\DEF_LOG_LEVEL, $writeMode); $logPhpFile->SetAffixStr($strExtraInfo); $this->m_arrayLog[$strFileName] = $logPhpFile; } #移除log对象,如果存在的话 private function RemoveLogObj($logName) { $logObj = GetLogObj($logName); unset($logObj); } #根据log名,获得Log对象 public function &GetLogObj($logName) { if (!array_key_exists($logName, $this->m_arrayLog)) { return null; } return $this->m_arrayLog[$logName]; } public function Debug($info) { foreach ($this->m_arrayLog as $log) { $log->Debug($info); } } public function Info($info) { foreach ($this->m_arrayLog as $log) { $log->Info($info); } } public function Warn($info) { foreach ($this->m_arrayLog as $log) { $log->Warn($info); } } public function Error($info) { foreach ($this->m_arrayLog as $log) { $log->Error($info); } } public function Fatal($info) { foreach ($this->m_arrayLog as $log) { $log->Fatal($info); } } }