From 23abd776c72445da3af125bcb26ec13c19341b39 Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 10 二月 2025 15:59:49 +0800
Subject: [PATCH] 10382 【后台】买断版充值回调日志按小时分割;
---
Common/MultiLogging.php | 170 +++++++++++++++++++++++++-------------------------------
1 files changed, 75 insertions(+), 95 deletions(-)
diff --git a/Common/MultiLogging.php b/Common/MultiLogging.php
index 227035d..f8b8b05 100644
--- a/Common/MultiLogging.php
+++ b/Common/MultiLogging.php
@@ -1,132 +1,112 @@
<?php
+
namespace MultiLogging;
-#创建日期:2012-4-13 下午4:10:48
-#作者:zhouliang
+#鍒涘缓鏃ユ湡锛�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='' )
+ #涓�浜涙寚瀹氱洰褰曟椂甯哥敤鐨勫畾涔�
+ const strLogDir = "\\InterfaceLog";
+
+ #姣忔璁板綍LOG鍚屾椂鍐欏叆鍒拌繖涓変釜log
+ private $m_arrayLog = null;
+
+ #鏍圭洰褰�
+ private $m_strDirRoot = '';
+
+ #鍙傛暟$strRootDir涓烘牴鐩綍锛屾寚瀹氬悗锛屼互鍚庢瘡娆℃柊鍔犵殑鏃ュ織瀵硅薄閮戒細浠ユ涓烘牴鐩綍
+ #$strFileDir,鏍圭洰褰曠殑涓嬬骇鐩綍(涓昏鏄负浜嗕究浜庡垎绫�)
+ #$strFileName,鎸囧畾鏃ュ織鐨勬爣璇嗙鏂囦欢鍚�
+ function __construct($strRootDir, $strFileDir, $strFileName, $strExtraInfo = '', $writeMode = \Log4Me\DEF_WRITE_MODE)
{
- if( bNewStyleLogging )
- {
- $this->m_strDirRoot=strLogBaseDir."\\ServerLog\\".\CommFunc\GetMonth()."\\";
+ if (bNewStyleLogging) {
+ $this->m_strDirRoot = strLogBaseDir . "\\ServerLog\\" . \CommFunc\GetMonth() . "\\";
+ } else {
+ $this->m_strDirRoot = $strRootDir;
}
- else
- {
- $this->m_strDirRoot=$strRootDir;
- }
-
- #构造日志对象和数组
-
- $this->m_arrayLog=array();
- $this->AddLogObj( $strFileDir, $strFileName, $strExtraInfo );
-
+
+ #鏋勯�犳棩蹇楀璞″拰鏁扮粍
+
+ $this->m_arrayLog = array();
+ $this->AddLogObj($strFileDir, $strFileName, $strExtraInfo, $writeMode);
}
-
- #增加log对象
- public function AddLogObj( $strFileDir, $strFileName, $strExtraInfo='' )
+
+ #澧炲姞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;
+ #鑾峰緱浠绘剰涓�涓棩蹇楀璞★紝鍙栧緱瀹冪殑鎵╁睍杈撳嚭鍐呭
+ 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 );
+
+ foreach ($this->m_arrayLog as $log) {
+ $log->SetAffixStr($strExtraInfo);
}
-
- if( bNewStyleLogging )
- {
- $strPhpDir=$this->m_strDirRoot.self::strLogDir."\\".date("d",time()).'\\'.$strFileDir;
+
+ if (bNewStyleLogging) {
+ $strPhpDir = $this->m_strDirRoot . self::strLogDir . "\\" . date("d", time()) . '\\' . $strFileDir;
+ } else {
+ $strPhpDir = $this->m_strDirRoot . self::strLogDir . '\\' . $strFileDir;
}
- else
- {
- $strPhpDir=$this->m_strDirRoot.self::strLogDir.'\\'.$strFileDir;
- }
-
- $logPhpFile=new \Log4Me\Log4Me( $strPhpDir, $strFileName );
- $logPhpFile->SetAffixStr( $strExtraInfo );
- $this->m_arrayLog[$strFileName]=$logPhpFile;
-
-
+ $logPhpFile = new \Log4Me\Log4Me($strPhpDir, $strFileName, \Log4Me\DEF_LOG_LEVEL, $writeMode);
+ $logPhpFile->SetAffixStr($strExtraInfo);
+ $this->m_arrayLog[$strFileName] = $logPhpFile;
}
-
- #移除log对象,如果存在的话
- private function RemoveLogObj( $logName )
+
+ #绉婚櫎log瀵硅薄锛屽鏋滃瓨鍦ㄧ殑璇�
+ private function RemoveLogObj($logName)
{
- $logObj=GetLogObj($logName);
- unset( $logObj );
+ $logObj = GetLogObj($logName);
+ unset($logObj);
}
-
- #根据log名,获得Log对象
- public function &GetLogObj( $logName )
+
+ #鏍规嵁log鍚嶏紝鑾峰緱Log瀵硅薄
+ public function &GetLogObj($logName)
{
- if( !array_key_exists( $logName, $this->m_arrayLog ) )
- {
+ if (!array_key_exists($logName, $this->m_arrayLog)) {
return null;
}
return $this->m_arrayLog[$logName];
}
-
- public function Debug( $info )
+
+ 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 );
+ foreach ($this->m_arrayLog as $log) {
+ $log->Debug($info);
}
}
-
- public function Warn( $info )
+
+ public function Info($info)
{
- foreach( $this->m_arrayLog as $log )
- {
- $log->Warn( $info );
+ foreach ($this->m_arrayLog as $log) {
+ $log->Info($info);
}
}
-
- public function Error( $info )
+
+ public function Warn($info)
{
- foreach( $this->m_arrayLog as $log )
- {
- $log->Error( $info );
+ foreach ($this->m_arrayLog as $log) {
+ $log->Warn($info);
}
}
-
- public function Fatal( $info )
+
+ public function Error($info)
{
- foreach( $this->m_arrayLog as $log )
- {
- $log->Fatal( $info );
+ foreach ($this->m_arrayLog as $log) {
+ $log->Error($info);
+ }
+ }
+
+ public function Fatal($info)
+ {
+ foreach ($this->m_arrayLog as $log) {
+ $log->Fatal($info);
}
}
}
-
-?>
\ No newline at end of file
--
Gitblit v1.8.0