Kaynağa Gözat

Log.Error也改成FiberLog

tanghai 2 yıl önce
ebeveyn
işleme
fec3740757
20 değiştirilmiş dosya ile 60 ekleme ve 53 silme
  1. 2 2
      Unity/Assets/Scripts/Core/Fiber/Module/Actor/MessageInnerSenderSystem.cs
  2. 1 1
      Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs
  3. 2 2
      Unity/Assets/Scripts/Core/Fiber/Module/Timer/TimerComponent.cs
  4. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/Main/NetClient2Main_SessionDisposeHandler.cs
  5. 4 4
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs
  6. 4 3
      Unity/Assets/Scripts/Hotfix/Server/Module/AOI/AOIManagerComponentSystem.cs
  7. 7 6
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs
  8. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs
  9. 8 5
      Unity/Assets/Scripts/Hotfix/Server/Module/DB/DBComponentSystem.cs
  10. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Message/MessageOuterSenderSystem.cs
  11. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/RobotCase/ARobotCase.cs
  12. 5 4
      Unity/Assets/Scripts/Hotfix/Share/Module/AI/AIComponentSystem.cs
  13. 6 6
      Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MessageHandler.cs
  14. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  15. 3 3
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs
  16. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Move/MoveComponentSystem.cs
  17. 1 1
      Unity/Assets/Scripts/HotfixView/Client/Demo/Unit/AnimatorComponentSystem.cs
  18. 1 1
      Unity/Assets/Scripts/HotfixView/Client/LockStep/LSAnimatorComponentSystem.cs
  19. 3 3
      Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesComponent.cs
  20. 5 4
      Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesLoaderComponent.cs

+ 2 - 2
Unity/Assets/Scripts/Core/Fiber/Module/Actor/MessageInnerSenderSystem.cs

@@ -50,7 +50,7 @@ namespace ET
             MailBoxComponent mailBoxComponent = self.Fiber().Mailboxes.Get(actorId.InstanceId);
             if (mailBoxComponent == null)
             {
-                Log.Warning($"actor not found mailbox, from: {actorId} current: {fiber.Address} {message}");
+                self.Fiber().Warning($"actor not found mailbox, from: {actorId} current: {fiber.Address} {message}");
                 if (message is IRequest request)
                 {
                     IResponse resp = MessageHelper.CreateResponse(request, ErrorCore.ERR_NotFoundActor);
@@ -196,7 +196,7 @@ namespace ET
             long costTime = endTime - beginTime;
             if (costTime > 200)
             {
-                Log.Warning($"actor rpc time > 200: {costTime} {iRequest}");
+                fiber.Warning($"actor rpc time > 200: {costTime} {iRequest}");
             }
             
             return response;

+ 1 - 1
Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -28,7 +28,7 @@ namespace ET
             // 一个协程队列一帧处理超过100个,说明比较多了,打个warning,检查一下是否够正常
             if (level == 100)
             {
-                Log.Warning($"too much coroutine level: {coroutineLockType} {key}");
+                self.Fiber().Warning($"too much coroutine level: {coroutineLockType} {key}");
             }
 
             self.nextFrameRun.Enqueue((coroutineLockType, key, level));

+ 2 - 2
Unity/Assets/Scripts/Core/Fiber/Module/Timer/TimerComponent.cs

@@ -272,7 +272,7 @@ namespace ET
             long timeNow = self.GetNow();
             if (tillTime < timeNow)
             {
-                Log.Error($"new once time too small: {tillTime}");
+                self.Fiber().Error($"new once time too small: {tillTime}");
             }
 
             TimerAction timer = TimerAction.Create(self.GetId(), TimerClass.OnceTimer, timeNow, tillTime - timeNow, type, args);
@@ -313,7 +313,7 @@ namespace ET
         {
             if (time < 100)
             {
-                Log.Error($"time too small: {time}");
+                self.Fiber().Error($"time too small: {time}");
                 return 0;
             }
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/Main/NetClient2Main_SessionDisposeHandler.cs

@@ -5,7 +5,7 @@
     {
         protected override async ETTask Run(Scene entity, NetClient2Main_SessionDispose message)
         {
-            Log.Error($"session dispose, error: {message.Error}");
+            entity.Fiber.Error($"session dispose, error: {message.Error}");
             await ETTask.CompletedTask;
         }
     }

+ 4 - 4
Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs

@@ -10,7 +10,7 @@ namespace ET.Server
         {
             Room room = root.GetComponent<Room>();
             FrameBuffer frameBuffer = room.FrameBuffer;
-            
+            Fiber fiber = root.Fiber;
             if (message.Frame % (1000 / LSConstValue.UpdateInterval) == 0)
             {
                 long nowFrameTime = room.FixedTimeCounter.FrameTime(message.Frame);
@@ -21,20 +21,20 @@ namespace ET.Server
 
             if (message.Frame < room.AuthorityFrame)  // 小于AuthorityFrame,丢弃
             {
-                Log.Warning($"FrameMessage < AuthorityFrame discard: {message}");
+                fiber.Warning($"FrameMessage < AuthorityFrame discard: {message}");
                 return;
             }
 
             if (message.Frame > room.AuthorityFrame + 10)  // 大于AuthorityFrame + 10,丢弃
             {
-                Log.Warning($"FrameMessage > AuthorityFrame + 10 discard: {message}");
+                fiber.Warning($"FrameMessage > AuthorityFrame + 10 discard: {message}");
                 return;
             }
             
             OneFrameInputs oneFrameInputs = frameBuffer.FrameInputs(message.Frame);
             if (oneFrameInputs == null)
             {
-                Log.Error($"FrameMessageHandler get frame is null: {message.Frame}, max frame: {frameBuffer.MaxFrame}");
+                fiber.Error($"FrameMessageHandler get frame is null: {message.Frame}, max frame: {frameBuffer.MaxFrame}");
                 return;
             }
             oneFrameInputs.Inputs[message.PlayerId] = message.Input;

+ 4 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/AOI/AOIManagerComponentSystem.cs

@@ -51,6 +51,7 @@ namespace ET.Server
                 return;
             }
 
+            Fiber fiber = self.Fiber();
             // 通知订阅该Cell Leave的Unit
             aoiEntity.Cell.Remove(aoiEntity);
             foreach (KeyValuePair<long, AOIEntity> kv in aoiEntity.Cell.SubsLeaveEntities)
@@ -70,16 +71,16 @@ namespace ET.Server
                 Cell cell = self.GetCell(cellId);
                 aoiEntity.UnSubLeave(cell);
             }
-
+    
             // 检查
             if (aoiEntity.SeeUnits.Count > 1)
             {
-                Log.Error($"aoiEntity has see units: {aoiEntity.SeeUnits.Count}");
+                fiber.Error($"aoiEntity has see units: {aoiEntity.SeeUnits.Count}");
             }
 
             if (aoiEntity.BeSeeUnits.Count > 1)
             {
-                Log.Error($"aoiEntity has beSee units: {aoiEntity.BeSeeUnits.Count}");
+                fiber.Error($"aoiEntity has beSee units: {aoiEntity.BeSeeUnits.Count}");
             }
         }
 

+ 7 - 6
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs

@@ -10,20 +10,21 @@ namespace ET.Server
         public async ETTask Handle(Entity entity, Address fromAddress, MessageObject actorMessage)
         {
             using MessageObject _ = actorMessage;
+            Fiber fiber = entity.Fiber();
             if (actorMessage is not Message message)
             {
-                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
                 return;
             }
 
             if (entity is not E e)
             {
-                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
+                fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
                 return;
             }
             
             MessageResponse response = new() {RpcId = message.RpcId};
-            entity.Root().GetComponent<MessageInnerSender>().Reply(fromAddress, response);
+            fiber.Root.GetComponent<MessageInnerSender>().Reply(fromAddress, response);
 
             await this.Run(e, message);
         }
@@ -51,21 +52,21 @@ namespace ET.Server
             try
             {
                 using MessageObject _ = actorMessage;
+                Fiber fiber = entity.Fiber();
                 if (actorMessage is not Request request)
                 {
-                    Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
+                    fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
                     return;
                 }
 
                 if (entity is not E ee)
                 {
-                    Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
+                    fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
                     return;
                 }
 
                 int rpcId = request.RpcId;
                 Response response = ObjectPool.Instance.Fetch<Response>();
-                Fiber fiber = entity.Fiber();
                 try
                 {
                     await this.Run(ee, request, response);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs

@@ -20,7 +20,7 @@ namespace ET.Server
                 }
                 catch (Exception e)
                 {
-                    Log.Error($"move timer error: {self.Id}\n{e}");
+                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }

+ 8 - 5
Unity/Assets/Scripts/Hotfix/Server/Module/DB/DBComponentSystem.cs

@@ -128,9 +128,10 @@ namespace ET.Server
 
 	    public static async ETTask Save<T>(this DBComponent self, T entity, string collection = null) where T : Entity
 	    {
+		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
-			    Log.Error($"save entity is null: {typeof (T).FullName}");
+			    fiber.Error($"save entity is null: {typeof (T).FullName}");
 
 			    return;
 		    }
@@ -140,7 +141,7 @@ namespace ET.Server
 			    collection = entity.GetType().FullName;
 		    }
 
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, entity.Id % DBComponent.TaskCount))
+		    using (await fiber.CoroutineLockComponent.Wait(CoroutineLockType.DB, entity.Id % DBComponent.TaskCount))
 		    {
 			    await self.GetCollection(collection).ReplaceOneAsync(d => d.Id == entity.Id, entity, new ReplaceOptions { IsUpsert = true });
 		    }
@@ -148,9 +149,10 @@ namespace ET.Server
 
 	    public static async ETTask Save<T>(this DBComponent self, long taskId, T entity, string collection = null) where T : Entity
 	    {
+		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
-			    Log.Error($"save entity is null: {typeof (T).FullName}");
+			    fiber.Error($"save entity is null: {typeof (T).FullName}");
 
 			    return;
 		    }
@@ -160,7 +162,7 @@ namespace ET.Server
 			    collection = entity.GetType().FullName;
 		    }
 
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
+		    using (await fiber.CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
 		    {
 			    await self.GetCollection(collection).ReplaceOneAsync(d => d.Id == entity.Id, entity, new ReplaceOptions { IsUpsert = true });
 		    }
@@ -168,9 +170,10 @@ namespace ET.Server
 
 	    public static async ETTask Save(this DBComponent self, long id, List<Entity> entities)
 	    {
+		    Fiber fiber = self.Fiber();
 		    if (entities == null)
 		    {
-			    Log.Error($"save entity is null");
+			    fiber.Error($"save entity is null");
 			    return;
 		    }
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Message/MessageOuterSenderSystem.cs

@@ -234,7 +234,7 @@ namespace ET.Server
             long costTime = endTime - beginTime;
             if (costTime > 200)
             {
-                Log.Warning($"actor rpc time > 200: {costTime} {iRequest}");
+                fiber.Warning($"actor rpc time > 200: {costTime} {iRequest}");
             }
 
             return response;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/RobotCase/ARobotCase.cs

@@ -9,15 +9,15 @@ namespace ET.Server
         public override async ETTask Handle(RobotInvokeArgs a)
         {
             using RobotCase robotCase = await a.Fiber.Root.GetComponent<RobotCaseComponent>().New();
-            
+            Fiber fiber = robotCase.Fiber();
             try
             {
                 await this.Run(robotCase);
             }
             catch (System.Exception e)
             {
-                Log.Error($"{robotCase.Zone()} {e}");
-                robotCase.Fiber().Console($"RobotCase Error {this.GetType().FullName}:\n\t{e}");
+                fiber.Error($"{robotCase.Zone()} {e}");
+                fiber.Console($"RobotCase Error {this.GetType().FullName}:\n\t{e}");
             }
         }
     }

+ 5 - 4
Unity/Assets/Scripts/Hotfix/Share/Module/AI/AIComponentSystem.cs

@@ -18,7 +18,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    Log.Error($"move timer error: {self.Id}\n{e}");
+                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }
@@ -41,9 +41,10 @@ namespace ET
 
         private static void Check(this AIComponent self)
         {
+            Fiber fiber = self.Fiber();
             if (self.Parent == null)
             {
-                self.Fiber().TimerComponent.Remove(ref self.Timer);
+                fiber.TimerComponent.Remove(ref self.Timer);
                 return;
             }
 
@@ -56,7 +57,7 @@ namespace ET
 
                 if (aaiHandler == null)
                 {
-                    Log.Error($"not found aihandler: {aiConfig.Name}");
+                    fiber.Error($"not found aihandler: {aiConfig.Name}");
                     continue;
                 }
 
@@ -72,7 +73,7 @@ namespace ET
                 }
 
                 self.Cancel(); // 取消之前的行为
-                ETCancellationToken cancellationToken = new ETCancellationToken();
+                ETCancellationToken cancellationToken = new();
                 self.CancellationToken = cancellationToken;
                 self.Current = aiConfig.Id;
 

+ 6 - 6
Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MessageHandler.cs

@@ -10,15 +10,16 @@ namespace ET
         public async ETTask Handle(Entity entity, Address fromAddress, MessageObject actorMessage)
         {
             using MessageObject _ = actorMessage;
+            Fiber fiber = entity.Fiber();
             if (actorMessage is not Message msg)
             {
-                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
                 return;
             }
 
             if (entity is not E e)
             {
-                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
+                fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
                 return;
             }
 
@@ -53,22 +54,21 @@ namespace ET
             try
             {
                 using MessageObject _ = actorMessage;
-                
+                Fiber fiber = entity.Fiber();
                 if (actorMessage is not Request request)
                 {
-                    Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
+                    fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
                     return;
                 }
 
                 if (entity is not E ee)
                 {
-                    Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
+                    fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
                     return;
                 }
 
                 int rpcId = request.RpcId;
                 Response response = ObjectPool.Instance.Fetch<Response>();
-                Fiber fiber = entity.Fiber();
                 try
                 {
                     await this.Run(ee, request, response);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs

@@ -17,7 +17,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    Log.Error($"move timer error: {self.Id}\n{e}");
+                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs

@@ -17,7 +17,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    Log.Error($"session idle checker timer error: {self.Id}\n{e}");
+                    self.Fiber().Error($"session idle checker timer error: {self.Id}\n{e}");
                 }
             }
         }
@@ -33,8 +33,8 @@ namespace ET
         {
             self.Fiber().TimerComponent?.Remove(ref self.RepeatedTimer);
         }
-        
-        public const int CheckInteral = 2000;
+
+        private const int CheckInteral = 2000;
 
         private static void Check(this SessionIdleCheckerComponent self)
         {

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Move/MoveComponentSystem.cs

@@ -19,7 +19,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    Log.Error($"move timer error: {self.Id}\n{e}");
+                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/Demo/Unit/AnimatorComponentSystem.cs

@@ -89,7 +89,7 @@ namespace ET.Client
 			float motionSpeed = animationClip.length / time;
 			if (motionSpeed < 0.01f || motionSpeed > 1000f)
 			{
-				Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
+				self.Fiber().Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
 				return;
 			}
 			self.MotionType = motionType;

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/LockStep/LSAnimatorComponentSystem.cs

@@ -89,7 +89,7 @@ namespace ET.Client
 			float motionSpeed = animationClip.length / time;
 			if (motionSpeed < 0.01f || motionSpeed > 1000f)
 			{
-				Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
+				self.Fiber().Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
 				return;
 			}
 			self.MotionType = motionType;

+ 3 - 3
Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesComponent.cs

@@ -353,7 +353,7 @@ namespace ET.Client
                     }
                     else
                     {
-                        Log.Error($"assets bundle not found: {assetBundleName}");
+                        self.Fiber().Error($"assets bundle not found: {assetBundleName}");
                     }
                 }
 
@@ -375,7 +375,7 @@ namespace ET.Client
             if (assetBundle == null)
             {
                 // 获取资源的时候会抛异常,这个地方不直接抛异常,因为有些地方需要Load之后判断是否Load成功
-                Log.Warning($"assets bundle not found: {assetBundleName}");
+                self.Fiber().Warning($"assets bundle not found: {assetBundleName}");
                 return;
             }
 
@@ -507,7 +507,7 @@ namespace ET.Client
             if (assetBundle == null)
             {
                 // 获取资源的时候会抛异常,这个地方不直接抛异常,因为有些地方需要Load之后判断是否Load成功
-                Log.Warning($"assets bundle not found: {assetBundleName}");
+                self.Fiber().Warning($"assets bundle not found: {assetBundleName}");
                 return null;
             }
 

+ 5 - 4
Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesLoaderComponent.cs

@@ -47,11 +47,12 @@ namespace ET.Client
 
         public static async ETTask LoadAsync(this ResourcesLoaderComponent self, string ab)
         {
-            using CoroutineLock coroutineLock = await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.ResourcesLoader, ab.GetHashCode(), 0);
-
+            Fiber fiber = self.Fiber();
+            using CoroutineLock coroutineLock = await fiber.CoroutineLockComponent.Wait(CoroutineLockType.ResourcesLoader, ab.GetHashCode(), 0);
+            
             if (self.IsDisposed)
             {
-                Log.Error($"resourceload already disposed {ab}");
+                fiber.Error($"resourceload already disposed {ab}");
                 return;
             }
 
@@ -61,7 +62,7 @@ namespace ET.Client
             }
 
             self.LoadedResource.Add(ab);
-            await self.Root().GetComponent<ResourcesComponent>().LoadBundleAsync(ab);
+            await fiber.Root.GetComponent<ResourcesComponent>().LoadBundleAsync(ab);
         }
         
         [EntitySystem]