<?php
|
namespace MultiLogging;
|
#´´½¨ÈÕÆÚ£º2012-4-13 ÏÂÎç4:10:48
|
#×÷Õߣºzhouliang
|
include_once 'Log4Me.php';
|
include_once 'BaseConfig.php';
|
|
class MultiLogging
|
{
|
#һЩָ¶¨Ä¿Â¼Ê±³£Óõ͍Òå
|
const strLogDir="\\InterfaceLog";
|
|
#ÿ´Î¼Ç¼LOGͬʱдÈëµ½ÕâÈý¸ölog
|
private $m_arrayLog=null;
|
|
#¸ùĿ¼
|
private $m_strDirRoot='';
|
|
#²ÎÊý$strRootDirΪ¸ùĿ¼£¬Ö¸¶¨ºó£¬ÒÔºóÿ´ÎмӵÄÈÕÖ¾¶ÔÏó¶¼»áÒÔ´ËΪ¸ùĿ¼
|
#$strFileDir,¸ùĿ¼µÄϼ¶Ä¿Â¼(Ö÷ÒªÊÇΪÁ˱ãÓÚ·ÖÀà)
|
#$strFileName,Ö¸¶¨ÈÕÖ¾µÄ±êʶ·ûÎļþÃû
|
function __construct( $strRootDir, $strFileDir, $strFileName, $strExtraInfo='' )
|
{
|
if( bNewStyleLogging )
|
{
|
$this->m_strDirRoot=strLogBaseDir."\\ServerLog\\".\CommFunc\GetMonth()."\\";
|
}
|
else
|
{
|
$this->m_strDirRoot=$strRootDir;
|
}
|
|
#¹¹ÔìÈÕÖ¾¶ÔÏóºÍÊý×é
|
|
$this->m_arrayLog=array();
|
$this->AddLogObj( $strFileDir, $strFileName, $strExtraInfo );
|
|
}
|
|
#Ôö¼Ólog¶ÔÏó
|
public function AddLogObj( $strFileDir, $strFileName, $strExtraInfo='' )
|
{
|
#»ñµÃÈÎÒâÒ»¸öÈÕÖ¾¶ÔÏó£¬È¡µÃËüµÄÀ©Õ¹Êä³öÄÚÈÝ
|
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 );
|
$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 );
|
}
|
}
|
}
|
|
?>
|