Explorar o código

去掉FiberLog,原因是很多底层库没法获取Fiber,导致纤程中没法打印底层库的FiberLog,
比如ETTask的异常Log只能使用Log.Exception, 就无法打印日志到相应的纤程日志文件中。

解决办法:
Fiber增加一个Instance,纤程调度的时候会给Instance赋值,并且这个Instance标记为internal,
只能在Log中使用。上层逻辑绝对不允许使用,会非常危险。

以后打印日志只需要用Log类即可

tanghai %!s(int64=2) %!d(string=hai) anos
pai
achega
f2f341993b
Modificáronse 66 ficheiros con 190 adicións e 443 borrados
  1. 0 91
      Share/Analyzer/Analyzer/FiberLogAnalyzer.cs
  2. 2 2
      Unity/Assets/Scripts/Core/Entity/Scene.cs
  3. 5 0
      Unity/Assets/Scripts/Core/Fiber/Fiber.cs
  4. 2 2
      Unity/Assets/Scripts/Core/Fiber/Module/Actor/ProcessInnerSenderSystem.cs
  5. 1 1
      Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs
  6. 2 2
      Unity/Assets/Scripts/Core/Fiber/Module/Timer/TimerComponent.cs
  7. 0 6
      Unity/Assets/Scripts/Core/Network/AService.cs
  8. 0 8
      Unity/Assets/Scripts/Core/Network/KChannel.cs
  9. 2 2
      Unity/Assets/Scripts/Core/Network/KService.cs
  10. 0 8
      Unity/Assets/Scripts/Core/Network/TChannel.cs
  11. 2 2
      Unity/Assets/Scripts/Core/Network/TService.cs
  12. 1 9
      Unity/Assets/Scripts/Core/Network/WChannel.cs
  13. 2 2
      Unity/Assets/Scripts/Core/Network/WService.cs
  14. 4 0
      Unity/Assets/Scripts/Core/World/Module/Fiber/MainThreadScheduler.cs
  15. 3 1
      Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadPoolScheduler.cs
  16. 1 0
      Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadScheduler.cs
  17. 0 127
      Unity/Assets/Scripts/Core/World/Module/Log/FiberLog.cs
  18. 0 11
      Unity/Assets/Scripts/Core/World/Module/Log/FiberLog.cs.meta
  19. 19 14
      Unity/Assets/Scripts/Core/World/Module/Log/Log.cs
  20. 2 2
      Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_Attack.cs
  21. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_XunLuo.cs
  22. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/Main/Login/EnterMapHelper.cs
  23. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/Main/NetClient2Main_SessionDisposeHandler.cs
  24. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Main2NetClient_LoginHandler.cs
  25. 2 2
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Ping/PingComponentSystem.cs
  26. 3 4
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterAddressComponentSystem.cs
  27. 4 4
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterCheckComponentSystem.cs
  28. 8 8
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterHelper.cs
  29. 3 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/LSClientHelper.cs
  30. 4 5
      Unity/Assets/Scripts/Hotfix/Client/LockStep/OneFrameInputsHandler.cs
  31. 2 3
      Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_CheckHashFailHandler.cs
  32. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Benchmark/C2G_BenchmarkHandler.cs
  33. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Realm/C2R_LoginHandler.cs
  34. 2 2
      Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/Console/CreateRobotConsoleHandler.cs
  35. 7 7
      Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/RobotConsoleHandler.cs
  36. 3 4
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/FrameMessageHandler.cs
  37. 2 2
      Unity/Assets/Scripts/Hotfix/Server/Module/AOI/AOIManagerComponentSystem.cs
  38. 8 8
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs
  39. 4 4
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationProxyComponentSystem.cs
  40. 4 4
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs
  41. 2 2
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs
  42. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderSystem.cs
  43. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/DB/DBComponentSystem.cs
  44. 2 2
      Unity/Assets/Scripts/Hotfix/Server/Module/Http/HttpComponentSystem.cs
  45. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/Message/ProcessOuterSenderSystem.cs
  46. 2 3
      Unity/Assets/Scripts/Hotfix/Server/Module/RobotCase/ARobotCase.cs
  47. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_Router.cs
  48. 34 36
      Unity/Assets/Scripts/Hotfix/Server/Module/Router/RouterComponentSystem.cs
  49. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/AI/AIComponentSystem.cs
  50. 4 5
      Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MessageHandler.cs
  51. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Console/ConsoleComponentSystem.cs
  52. 3 3
      Unity/Assets/Scripts/Hotfix/Share/Module/Console/ReloadConfigConsoleHandler.cs
  53. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/NetComponentSystem.cs
  54. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  55. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs
  56. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Move/MoveComponentSystem.cs
  57. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Recast/PathfindingComponentSystem.cs
  58. 1 1
      Unity/Assets/Scripts/HotfixView/Client/Demo/Scene/SceneChangeStart_AddComponent.cs
  59. 1 2
      Unity/Assets/Scripts/HotfixView/Client/Demo/UI/UIHelp/UIHelpEvent.cs
  60. 1 1
      Unity/Assets/Scripts/HotfixView/Client/Demo/Unit/AnimatorComponentSystem.cs
  61. 1 1
      Unity/Assets/Scripts/HotfixView/Client/LockStep/LSAnimatorComponentSystem.cs
  62. 1 1
      Unity/Assets/Scripts/HotfixView/Client/LockStep/UI/UILSLobby/UILSLobbyComponentSystem.cs
  63. 2 2
      Unity/Assets/Scripts/Model/Share/LockStep/LSEntitySystemSingleton.cs
  64. 2 3
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionDispatcher.cs
  65. 4 5
      Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionHandler.cs
  66. 2 2
      Unity/Assets/Scripts/Model/Share/Module/Message/Session.cs

+ 0 - 91
Share/Analyzer/Analyzer/FiberLogAnalyzer.cs

@@ -1,91 +0,0 @@
-using System.Collections.Immutable;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Diagnostics;
-
-namespace ET.Analyzer;
-[DiagnosticAnalyzer(LanguageNames.CSharp)]
-public class FiberLogAnalyzer:DiagnosticAnalyzer
-{
-    public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(FiberLogAnalyzerRule.Rule);
-    
-    public override void Initialize(AnalysisContext context)
-    {
-        if (!AnalyzerGlobalSetting.EnableAnalyzer)
-        {
-            return;
-        }
-        context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
-        context.EnableConcurrentExecution();
-        context.RegisterCompilationStartAction((analysisContext =>
-        {
-            if (AnalyzerHelper.IsAssemblyNeedAnalyze(analysisContext.Compilation.AssemblyName, AnalyzeAssembly.AllModelHotfix))
-            {
-                analysisContext.RegisterSyntaxNodeAction(AnalyzeMemberAccessExpression,SyntaxKind.InvocationExpression);
-            }
-        } ));
-    }
-
-    private void AnalyzeMemberAccessExpression(SyntaxNodeAnalysisContext context)
-    {
-        if (!(context.Node is InvocationExpressionSyntax invocationExpressionSyntax))
-        {
-            return;
-        }
-
-        var methodSymbol = context.SemanticModel.GetSymbolInfo(invocationExpressionSyntax).Symbol as IMethodSymbol;
-
-        if (methodSymbol==null)
-        {
-            return;
-        }
-
-        // 筛选出调用ET.Log的日志输出
-        if (methodSymbol.ContainingType.ToString() != Definition.ETLog)
-        {
-            return;
-        }
-
-        if (invocationExpressionSyntax.GetNeareastAncestor<ClassDeclarationSyntax>() is not ClassDeclarationSyntax parentClassSyntax)
-        {
-            return;
-        }
-
-        if (context.SemanticModel.GetDeclaredSymbol(parentClassSyntax) is not INamedTypeSymbol parentClassSymbol)
-        {
-            return;
-        }
-
-        // 判断是否在实体类内部调用
-        if (parentClassSymbol.ToString()==Definition.EntityType|| parentClassSymbol.ToString()==Definition.LSEntityType || parentClassSymbol.BaseType?.ToString()==Definition.EntityType ||parentClassSymbol.BaseType?.ToString()==Definition.LSEntityType)
-        {
-            Diagnostic diagnostic = Diagnostic.Create(FiberLogAnalyzerRule.Rule, invocationExpressionSyntax?.GetLocation());
-            context.ReportDiagnostic(diagnostic);
-            return;
-        }
-
-        // 判断是否在含实体类参数的函数内调用
-        if (invocationExpressionSyntax.GetNeareastAncestor<MethodDeclarationSyntax>() is not MethodDeclarationSyntax methodDeclarationSyntax)
-        {
-            return;
-        }
-
-        if (context.SemanticModel.GetDeclaredSymbol(methodDeclarationSyntax) is not IMethodSymbol containningMethodSymbol)
-        {
-            return;
-        }
-
-        foreach (var parameter in containningMethodSymbol.Parameters)
-        {
-            var parameterType = parameter.Type.ToString();
-            var parameterBaseType = parameter.Type.BaseType?.ToString();
-            if (parameterType== Definition.EntityType|| parameterType==Definition.LSEntityType ||parameterBaseType==Definition.EntityType ||parameterBaseType==Definition.LSEntityType)
-            {
-                Diagnostic diagnostic = Diagnostic.Create(FiberLogAnalyzerRule.Rule, invocationExpressionSyntax?.GetLocation());
-                context.ReportDiagnostic(diagnostic);
-                return;
-            }
-        }
-    }
-}

+ 2 - 2
Unity/Assets/Scripts/Core/Entity/Scene.cs

@@ -33,14 +33,14 @@ namespace ET
             this.Fiber = fiber;
             this.IScene = this;
             this.IsRegister = true;
-            fiber.Info($"scene create: {this.SceneType} {this.Id} {this.InstanceId}");
+            Log.Info($"scene create: {this.SceneType} {this.Id} {this.InstanceId}");
         }
 
         public override void Dispose()
         {
             base.Dispose();
             
-            this.Fiber.Info($"scene dispose: {this.SceneType} {this.Id} {this.InstanceId}");
+            Log.Info($"scene dispose: {this.SceneType} {this.Id} {this.InstanceId}");
         }
         
         protected override string ViewName

+ 5 - 0
Unity/Assets/Scripts/Core/Fiber/Fiber.cs

@@ -15,6 +15,11 @@ namespace ET
     
     public class Fiber: IDisposable
     {
+        // 该字段只能框架使用,绝对不能改成public,改了后果自负
+        [StaticField]
+        [ThreadStatic]
+        internal static Fiber Instance;
+        
         public bool IsDisposed;
         
         public int Id;

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

@@ -50,7 +50,7 @@ namespace ET
             MailBoxComponent mailBoxComponent = self.Fiber().Mailboxes.Get(actorId.InstanceId);
             if (mailBoxComponent == null)
             {
-                self.Fiber().Warning($"actor not found mailbox, from: {actorId} current: {fiber.Address} {message}");
+                Log.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)
             {
-                fiber.Warning($"actor rpc time > 200: {costTime} {iRequest}");
+                Log.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)
             {
-                self.Fiber().Warning($"too much coroutine level: {coroutineLockType} {key}");
+                Log.Warning($"too much coroutine level: {coroutineLockType} {key}");
             }
 
             self.nextFrameRun.Enqueue((coroutineLockType, key, level));

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

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

+ 0 - 6
Unity/Assets/Scripts/Core/Network/AService.cs

@@ -7,7 +7,6 @@ namespace ET
 {
     public abstract class AService: IDisposable
     {
-        public ILog Log;
         public Action<long, IPEndPoint> AcceptCallback;
         public Action<long, ActorId, object> ReadCallback;
         public Action<long, int> ErrorCallback;
@@ -20,11 +19,6 @@ namespace ET
 		
         private readonly Queue<MemoryBuffer> pool = new();
 
-        protected AService(ILog log)
-        {
-            this.Log = log;
-        }
-
         public MemoryBuffer Fetch(int size = 0)
         {
             if (size > MaxMemoryBufferSize)

+ 0 - 8
Unity/Assets/Scripts/Core/Network/KChannel.cs

@@ -30,14 +30,6 @@ namespace ET
 				this.Id = value;
 			}
 		}
-
-		private ILog Log
-		{
-			get
-			{
-				return this.Service.Log;
-			}
-		}
 		
 		public uint RemoteConn { get; set; }
 

+ 2 - 2
Unity/Assets/Scripts/Core/Network/KService.cs

@@ -46,7 +46,7 @@ namespace ET
 
         public Socket Socket;
 
-        public KService(IPEndPoint ipEndPoint, ServiceType serviceType, ILog log): base(log)
+        public KService(IPEndPoint ipEndPoint, ServiceType serviceType)
         {
             this.ServiceType = serviceType;
             this.startTime = DateTime.UtcNow.Ticks;
@@ -70,7 +70,7 @@ namespace ET
             NetworkHelper.SetSioUdpConnReset(this.Socket);
         }
 
-        public KService(AddressFamily addressFamily, ServiceType serviceType, ILog log): base(log)
+        public KService(AddressFamily addressFamily, ServiceType serviceType)
         {
             this.ServiceType = serviceType;
             this.startTime = DateTime.UtcNow.Ticks;

+ 0 - 8
Unity/Assets/Scripts/Core/Network/TChannel.cs

@@ -28,14 +28,6 @@ namespace ET
 
 		private readonly byte[] sendCache = new byte[Packet.OpcodeLength + Packet.ActorIdLength];
 		
-		private ILog Log
-		{
-			get
-			{
-				return this.Service.Log;
-			}
-		}
-
 		private void OnComplete(object sender, SocketAsyncEventArgs e)
 		{
 			this.Service.Queue.Enqueue(new TArgs() {ChannelId = this.Id, SocketAsyncEventArgs = e});

+ 2 - 2
Unity/Assets/Scripts/Core/Network/TService.cs

@@ -32,12 +32,12 @@ namespace ET
 
 		public ConcurrentQueue<TArgs> Queue = new();
 
-		public TService(AddressFamily addressFamily, ServiceType serviceType, ILog log): base(log)
+		public TService(AddressFamily addressFamily, ServiceType serviceType)
 		{
 			this.ServiceType = serviceType;
 		}
 
-		public TService(IPEndPoint ipEndPoint, ServiceType serviceType, ILog log): base(log)
+		public TService(IPEndPoint ipEndPoint, ServiceType serviceType)
 		{
 			this.ServiceType = serviceType;
 			this.acceptor = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

+ 1 - 9
Unity/Assets/Scripts/Core/Network/WChannel.cs

@@ -24,16 +24,8 @@ namespace ET
         
         public IPEndPoint RemoteAddress { get; set; }
 
-        private CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
+        private CancellationTokenSource cancellationTokenSource = new();
         
-        private ILog Log
-        {
-            get
-            {
-                return this.Service.Log;
-            }
-        }
-
         public WChannel(long id, HttpListenerWebSocketContext webSocketContext, WService service)
         {
             this.Service = service;

+ 2 - 2
Unity/Assets/Scripts/Core/Network/WService.cs

@@ -16,7 +16,7 @@ namespace ET
 
         public ThreadSynchronizationContext ThreadSynchronizationContext;
 
-        public WService(ThreadSynchronizationContext threadSynchronizationContext, IEnumerable<string> prefixs, ILog log): base(log)
+        public WService(ThreadSynchronizationContext threadSynchronizationContext, IEnumerable<string> prefixs)
         {
             this.ThreadSynchronizationContext = threadSynchronizationContext;
             
@@ -25,7 +25,7 @@ namespace ET
             StartAccept(prefixs).Coroutine();
         }
         
-        public WService(ThreadSynchronizationContext threadSynchronizationContext, ILog log): base(log)
+        public WService(ThreadSynchronizationContext threadSynchronizationContext)
         {
             this.ThreadSynchronizationContext = threadSynchronizationContext;
         }

+ 4 - 0
Unity/Assets/Scripts/Core/World/Module/Fiber/MainThreadScheduler.cs

@@ -47,8 +47,10 @@ namespace ET
                     continue;
                 }
                 
+                Fiber.Instance = fiber;
                 SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                 fiber.Update();
+                Fiber.Instance = null;
                 
                 this.idQueue.Enqueue(id);
             }
@@ -75,8 +77,10 @@ namespace ET
                     continue;
                 }
 
+                Fiber.Instance = fiber;
                 SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                 fiber.LateUpdate();
+                Fiber.Instance = null;
                 
                 this.idQueue.Enqueue(id);
             }

+ 3 - 1
Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadPoolScheduler.cs

@@ -51,11 +51,13 @@ namespace ET
                 {
                     continue;
                 }
-                
+
+                Fiber.Instance = fiber;
                 SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
                 fiber.Update();
                 fiber.LateUpdate();
                 SynchronizationContext.SetSynchronizationContext(null);
+                Fiber.Instance = null;
 
                 this.idQueue.Enqueue(id);
 

+ 1 - 0
Unity/Assets/Scripts/Core/World/Module/Fiber/ThreadScheduler.cs

@@ -20,6 +20,7 @@ namespace ET
         private void Loop(int fiberId)
         {
             Fiber fiber = fiberManager.Get(fiberId);
+            Fiber.Instance = fiber;
             SynchronizationContext.SetSynchronizationContext(fiber.ThreadSynchronizationContext);
             
             while (true)

+ 0 - 127
Unity/Assets/Scripts/Core/World/Module/Log/FiberLog.cs

@@ -1,127 +0,0 @@
-using System;
-using System.Diagnostics;
-
-namespace ET
-{
-    public static class FiberLog
-    {
-        private const int TraceLevel = 1;
-        private const int DebugLevel = 2;
-        private const int InfoLevel = 3;
-        private const int WarningLevel = 4;
-        
-        
-        [Conditional("DEBUG")]
-        public static void Debug(this Fiber self, string msg)
-        {
-            if (Options.Instance.LogLevel > DebugLevel)
-            {
-                return;
-            }
-            self.Log.Debug(msg);
-        }
-        
-        [Conditional("DEBUG")]
-        public static void Trace(this Fiber self, string msg)
-        {
-            if (Options.Instance.LogLevel > TraceLevel)
-            {
-                return;
-            }
-            
-            self.Log.Trace(msg);
-        }
-
-        public static void Info(this Fiber self, string msg)
-        {
-            if (Options.Instance.LogLevel > InfoLevel)
-            {
-                return;
-            }
-            self.Log.Info(msg);
-        }
-
-        public static void TraceInfo(this Fiber self, string msg)
-        {
-            if (Options.Instance.LogLevel > InfoLevel)
-            {
-                return;
-            }
-            self.Log.Trace(msg);
-        }
-
-        public static void Warning(this Fiber self, string msg)
-        {
-            if (Options.Instance.LogLevel > WarningLevel)
-            {
-                return;
-            }
-
-            self.Log.Warning(msg);
-        }
-
-        public static void Error(this Fiber self, string msg)
-        {
-            self.Log.Error(msg);
-        }
-
-        public static void Error(this Fiber self, Exception e)
-        {
-            self.Log.Error(e.ToString());
-        }
-        
-        public static void Console(this Fiber self, string msg)
-        {
-            if (Options.Instance.Console == 1)
-            {
-                System.Console.WriteLine(msg);
-            }
-            self.Log.Debug(msg);
-        }
-
-#if DOTNET
-        [Conditional("DEBUG")]
-        public static void Trace(this Fiber self, ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
-        {
-            if (Options.Instance.LogLevel > TraceLevel)
-            {
-                return;
-            }
-            self.Log.Trace(ref message);
-        }
-        [Conditional("DEBUG")]
-        public static void Warning(this Fiber self, ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
-        {
-            if (Options.Instance.LogLevel > WarningLevel)
-            {
-                return;
-            }
-            self.Log.Warning(ref message);
-        }
-
-        public static void Info(this Fiber self, ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
-        {
-            if (Options.Instance.LogLevel > InfoLevel)
-            {
-                return;
-            }
-            self.Log.Info(ref message);
-        }
-        
-        [Conditional("DEBUG")]
-        public static void Debug(this Fiber self, ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
-        {
-            if (Options.Instance.LogLevel > DebugLevel)
-            {
-                return;
-            }
-            self.Log.Debug(ref message);
-        }
-
-        public static void Error(this Fiber self, ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
-        {
-            self.Log.Error(ref message);
-        }
-#endif
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/World/Module/Log/FiberLog.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 0357cabeaecc01a469c570e5c84b844c
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 19 - 14
Unity/Assets/Scripts/Core/World/Module/Log/Log.cs

@@ -9,7 +9,11 @@ namespace ET
         private const int DebugLevel = 2;
         private const int InfoLevel = 3;
         private const int WarningLevel = 4;
-        
+
+        private static ILog GetLog()
+        {
+            return Fiber.Instance != null? Fiber.Instance.Log : Logger.Instance.Log;
+        }
         
         [Conditional("DEBUG")]
         public static void Debug(string msg)
@@ -18,7 +22,8 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Debug(msg);
+
+            GetLog().Debug(msg);
         }
         
         [Conditional("DEBUG")]
@@ -29,7 +34,7 @@ namespace ET
                 return;
             }
             StackTrace st = new(1, true);
-            Logger.Instance.Log.Trace($"{msg}\n{st}");
+            GetLog().Trace($"{msg}\n{st}");
         }
 
         public static void Info(string msg)
@@ -38,7 +43,7 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Info(msg);
+            GetLog().Info(msg);
         }
 
         public static void TraceInfo(string msg)
@@ -48,7 +53,7 @@ namespace ET
                 return;
             }
             StackTrace st = new(1, true);
-            Logger.Instance.Log.Trace($"{msg}\n{st}");
+            GetLog().Trace($"{msg}\n{st}");
         }
 
         public static void Warning(string msg)
@@ -57,18 +62,18 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Warning(msg);
+            GetLog().Warning(msg);
         }
 
         public static void Error(string msg)
         {
             StackTrace st = new(1, true);
-            Logger.Instance.Log.Error($"{msg}\n{st}");
+            GetLog().Error($"{msg}\n{st}");
         }
 
         public static void Error(Exception e)
         {
-            Logger.Instance.Log.Error(e.ToString());
+            GetLog().Error(e.ToString());
         }
         
         public static void Console(string msg)
@@ -77,7 +82,7 @@ namespace ET
             {
                 System.Console.WriteLine(msg);
             }
-            Logger.Instance.Log.Debug(msg);
+            GetLog().Debug(msg);
         }
 
 #if DOTNET
@@ -88,7 +93,7 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Trace(ref message);
+            GetLog().Trace(ref message);
         }
         [Conditional("DEBUG")]
         public static void Warning(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
@@ -97,7 +102,7 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Warning(ref message);
+            GetLog().Warning(ref message);
         }
 
         public static void Info(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
@@ -106,7 +111,7 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Info(ref message);
+            GetLog().Info(ref message);
         }
         [Conditional("DEBUG")]
         public static void Debug(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
@@ -115,12 +120,12 @@ namespace ET
             {
                 return;
             }
-            Logger.Instance.Log.Debug(ref message);
+            GetLog().Debug(ref message);
         }
 
         public static void Error(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message)
         {
-            Logger.Instance.Log.Error(ref message);
+            GetLog().Error(ref message);
         }
 #endif
     }

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_Attack.cs

@@ -25,11 +25,11 @@ namespace ET.Client
             // 停在当前位置
             fiber.Root.GetComponent<ClientSenderCompnent>().Send(new C2M_Stop());
             
-            fiber.Debug("开始攻击");
+            Log.Debug("开始攻击");
 
             for (int i = 0; i < 100000; ++i)
             {
-                fiber.Debug($"攻击: {i}次");
+                Log.Debug($"攻击: {i}次");
 
                 // 因为协程可能被中断,任何协程都要传入cancellationToken,判断如果是中断则要返回
                 await fiber.TimerComponent.WaitAsync(1000, cancellationToken);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_XunLuo.cs

@@ -24,7 +24,7 @@ namespace ET.Client
                 return;
             }
             
-            root.Fiber().Debug("开始巡逻");
+            Log.Debug("开始巡逻");
 
             while (true)
             {

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

@@ -18,7 +18,7 @@ namespace ET.Client
             }
             catch (Exception e)
             {
-                root.Fiber.Error(e);
+                Log.Error(e);
             }	
         }
         

+ 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)
         {
-            entity.Fiber.Error($"session dispose, error: {message.Error}");
+            Log.Error($"session dispose, error: {message.Error}");
             await ETTask.CompletedTask;
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Main2NetClient_LoginHandler.cs

@@ -36,7 +36,7 @@ namespace ET.Client
             root.AddComponent<SessionComponent>().Session = gateSession;
             G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await gateSession.Call(new C2G_LoginGate() { Key = r2CLogin.Key, GateId = r2CLogin.GateId });
 
-            root.Fiber().Debug("登陆gate成功!");
+            Log.Debug("登陆gate成功!");
 
             response.PlayerId = g2CLoginGate.PlayerId;
         }

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Ping/PingComponentSystem.cs

@@ -51,12 +51,12 @@ namespace ET.Client
                 catch (RpcException e)
                 {
                     // session断开导致ping rpc报错,记录一下即可,不需要打成error
-                    fiber.Info($"ping error: {self.Id} {e.Error}");
+                    Log.Info($"ping error: {self.Id} {e.Error}");
                     return;
                 }
                 catch (Exception e)
                 {
-                    fiber.Error($"ping error: \n{e}");
+                    Log.Error($"ping error: \n{e}");
                 }
             }
         }

+ 3 - 4
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterAddressComponentSystem.cs

@@ -24,14 +24,13 @@ namespace ET.Client
 
         private static async ETTask GetAllRouter(this RouterAddressComponent self)
         {
-            Fiber fiber = self.Fiber();
             string url = $"http://{self.RouterManagerHost}:{self.RouterManagerPort}/get_router?v={RandomGenerator.RandUInt32()}";
-            fiber.Debug($"start get router info: {url}");
+            Log.Debug($"start get router info: {url}");
             string routerInfo = await HttpClientHelper.Get(url);
-            fiber.Debug($"recv router info: {routerInfo}");
+            Log.Debug($"recv router info: {routerInfo}");
             HttpGetRouterResponse httpGetRouterResponse = MongoHelper.FromJson<HttpGetRouterResponse>(routerInfo);
             self.Info = httpGetRouterResponse;
-            fiber.Debug($"start get router info finish: {MongoHelper.ToJson(httpGetRouterResponse)}");
+            Log.Debug($"start get router info finish: {MongoHelper.ToJson(httpGetRouterResponse)}");
             
             // 打乱顺序
             RandomGenerator.BreakRank(self.Info.Routers);

+ 4 - 4
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterCheckComponentSystem.cs

@@ -48,16 +48,16 @@ namespace ET.Client
                     (uint localConn, uint remoteConn) = session.AService.GetChannelConn(sessionId);
                     
                     
-                    fiber.Info($"get recvLocalConn start: {root.Id} {realAddress} {localConn} {remoteConn}");
+                    Log.Info($"get recvLocalConn start: {root.Id} {realAddress} {localConn} {remoteConn}");
 
                     (uint recvLocalConn, IPEndPoint routerAddress) = await RouterHelper.GetRouterAddress(root, realAddress, localConn, remoteConn);
                     if (recvLocalConn == 0)
                     {
-                        fiber.Error($"get recvLocalConn fail: {root.Id} {routerAddress} {realAddress} {localConn} {remoteConn}");
+                        Log.Error($"get recvLocalConn fail: {root.Id} {routerAddress} {realAddress} {localConn} {remoteConn}");
                         continue;
                     }
                     
-                    fiber.Info($"get recvLocalConn ok: {root.Id} {routerAddress} {realAddress} {recvLocalConn} {localConn} {remoteConn}");
+                    Log.Info($"get recvLocalConn ok: {root.Id} {routerAddress} {realAddress} {recvLocalConn} {localConn} {remoteConn}");
 
                     realAddress = routerAddress;
                     session.RemoteAddress = realAddress.ToString();
@@ -68,7 +68,7 @@ namespace ET.Client
                 }
                 catch (Exception e)
                 {
-                    fiber.Error(e);
+                    Log.Error(e);
                 }
             }
         }

+ 8 - 8
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterHelper.cs

@@ -16,7 +16,7 @@ namespace ET.Client
                 throw new Exception($"get router fail: {root.Id} {address}");
             }
             
-            root.Fiber().Info($"get router: {recvLocalConn} {routerAddress}");
+            Log.Info($"get router: {recvLocalConn} {routerAddress}");
 
             Session routerSession = root.GetComponent<NetComponent>().Create(routerAddress, address, recvLocalConn);
             routerSession.AddComponent<PingComponent>();
@@ -27,14 +27,14 @@ namespace ET.Client
         
         public static async ETTask<(uint, IPEndPoint)> GetRouterAddress(Scene root, IPEndPoint address, uint localConn, uint remoteConn)
         {
-            root.Fiber().Info($"start get router address: {root.Id} {address} {localConn} {remoteConn}");
+            Log.Info($"start get router address: {root.Id} {address} {localConn} {remoteConn}");
             //return (RandomHelper.RandUInt32(), address);
             RouterAddressComponent routerAddressComponent = root.GetComponent<RouterAddressComponent>();
             IPEndPoint routerInfo = routerAddressComponent.GetAddress();
             
             uint recvLocalConn = await Connect(root, routerInfo, address, localConn, remoteConn);
             
-            root.Fiber().Info($"finish get router address: {root.Id} {address} {localConn} {remoteConn} {recvLocalConn} {routerInfo}");
+            Log.Info($"finish get router address: {root.Id} {address} {localConn} {remoteConn} {recvLocalConn} {routerInfo}");
             return (recvLocalConn, routerInfo);
         }
 
@@ -57,7 +57,7 @@ namespace ET.Client
             byte[] addressBytes = realAddress.ToString().ToByteArray();
             Array.Copy(addressBytes, 0, sendCache, 13, addressBytes.Length);
             Fiber fiber = root.Fiber;
-            fiber.Info($"router connect: {connectId} {localConn} {remoteConn} {routerAddress} {realAddress}");
+            Log.Info($"router connect: {connectId} {localConn} {remoteConn} {routerAddress} {realAddress}");
                 
             EndPoint recvIPEndPoint = new IPEndPoint(IPAddress.Any, 0);
 
@@ -70,7 +70,7 @@ namespace ET.Client
                 {
                     if (--count < 0)
                     {
-                        fiber.Error($"router connect timeout fail! {localConn} {remoteConn} {routerAddress} {realAddress}");
+                        Log.Error($"router connect timeout fail! {localConn} {remoteConn} {routerAddress} {realAddress}");
                         return 0;
                     }
                     lastSendTimer = timeNow;
@@ -86,20 +86,20 @@ namespace ET.Client
                     int messageLength = socket.ReceiveFrom(recvCache, ref recvIPEndPoint);
                     if (messageLength != 9)
                     {
-                        fiber.Error($"router connect error1: {connectId} {messageLength} {localConn} {remoteConn} {routerAddress} {realAddress}");
+                        Log.Error($"router connect error1: {connectId} {messageLength} {localConn} {remoteConn} {routerAddress} {realAddress}");
                         continue;
                     }
 
                     byte flag = recvCache[0];
                     if (flag != KcpProtocalType.RouterReconnectACK && flag != KcpProtocalType.RouterACK)
                     {
-                        fiber.Error($"router connect error2: {connectId} {synFlag} {flag} {localConn} {remoteConn} {routerAddress} {realAddress}");
+                        Log.Error($"router connect error2: {connectId} {synFlag} {flag} {localConn} {remoteConn} {routerAddress} {realAddress}");
                         continue;
                     }
 
                     uint recvRemoteConn = BitConverter.ToUInt32(recvCache, 1);
                     uint recvLocalConn = BitConverter.ToUInt32(recvCache, 5);
-                    fiber.Info($"router connect finish: {connectId} {recvRemoteConn} {recvLocalConn} {localConn} {remoteConn} {routerAddress} {realAddress}");
+                    Log.Info($"router connect finish: {connectId} {recvRemoteConn} {recvLocalConn} {localConn} {remoteConn} {routerAddress} {realAddress}");
                     return recvLocalConn;
                 }
             }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/LSClientHelper.cs

@@ -89,7 +89,7 @@ namespace ET.Client
                 return;
             }
             
-            room.Fiber().Debug($"save replay: {path} frame: {room.Replay.FrameInputs.Count}");
+            Log.Debug($"save replay: {path} frame: {room.Replay.FrameInputs.Count}");
             byte[] bytes = MemoryPackHelper.Serialize(room.Replay);
             File.WriteAllBytes(path, bytes);
         }
@@ -107,7 +107,7 @@ namespace ET.Client
             }
             
             int snapshotIndex = frame / LSConstValue.SaveLSWorldFrameCount;
-            room.Fiber().Debug($"jump replay start {room.AuthorityFrame} {frame} {snapshotIndex}");
+            Log.Debug($"jump replay start {room.AuthorityFrame} {frame} {snapshotIndex}");
             if (snapshotIndex != room.AuthorityFrame / LSConstValue.SaveLSWorldFrameCount || frame < room.AuthorityFrame)
             {
                 room.LSWorld.Dispose();
@@ -121,7 +121,7 @@ namespace ET.Client
             
             room.FixedTimeCounter.Reset(TimeInfo.Instance.ServerFrameTime() - frame * LSConstValue.UpdateInterval, 0);
 
-            room.Fiber().Debug($"jump replay finish {frame}");
+            Log.Debug($"jump replay finish {frame}");
         }
     }
 }

+ 4 - 5
Unity/Assets/Scripts/Hotfix/Client/LockStep/OneFrameInputsHandler.cs

@@ -8,10 +8,9 @@ namespace ET.Client
         protected override async ETTask Run(Scene root, OneFrameInputs input)
         {
             using var _ = input ; // 方法结束时回收消息
-            Fiber fiber = root.Fiber();
             Room room = root.GetComponent<Room>();
             
-            fiber.Debug($"OneFrameInputs: {room.AuthorityFrame + 1} {input.ToJson()}");
+            Log.Debug($"OneFrameInputs: {room.AuthorityFrame + 1} {input.ToJson()}");
                         
             FrameBuffer frameBuffer = room.FrameBuffer;
 
@@ -32,12 +31,12 @@ namespace ET.Client
                 // 回滚重新预测的时候,自己的输入不用变化
                 if (input != predictionInput)
                 {
-                    fiber.Debug($"frame diff: {predictionInput} {input}");
+                    Log.Debug($"frame diff: {predictionInput} {input}");
                     input.CopyTo(predictionInput);
                     // 回滚到frameBuffer.AuthorityFrame
-                    fiber.Debug($"roll back start {room.AuthorityFrame}");
+                    Log.Debug($"roll back start {room.AuthorityFrame}");
                     LSClientHelper.Rollback(room, room.AuthorityFrame);
-                    fiber.Debug($"roll back finish {room.AuthorityFrame}");
+                    Log.Debug($"roll back finish {room.AuthorityFrame}");
                 }
                 else // 对比成功
                 {

+ 2 - 3
Unity/Assets/Scripts/Hotfix/Client/LockStep/Room2C_CheckHashFailHandler.cs

@@ -5,18 +5,17 @@ namespace ET.Client
     {
         protected override async ETTask Run(Scene root, Room2C_CheckHashFail message)
         {
-            Fiber fiber = root.Fiber();
             LSWorld serverWorld = MongoHelper.Deserialize(typeof(LSWorld), message.LSWorldBytes, 0, message.LSWorldBytes.Length) as LSWorld;
             using (root.AddChild(serverWorld))
             {
-                fiber.Debug($"check hash fail, server: {message.Frame} {serverWorld.ToJson()}");
+                Log.Debug($"check hash fail, server: {message.Frame} {serverWorld.ToJson()}");
             }
 
             Room room = root.GetComponent<Room>();
             LSWorld clientWorld = room.GetLSWorld(SceneType.LockStepClient, message.Frame);
             using (root.AddChild(clientWorld))
             {
-                fiber.Debug($"check hash fail, client: {message.Frame} {clientWorld.ToJson()}");
+                Log.Debug($"check hash fail, client: {message.Frame} {clientWorld.ToJson()}");
             }
             
             message.Dispose();

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Benchmark/C2G_BenchmarkHandler.cs

@@ -10,7 +10,7 @@ namespace ET.Server
             BenchmarkServerComponent benchmarkServerComponent = session.Scene().GetComponent<BenchmarkServerComponent>();
             if (benchmarkServerComponent.Count++ % 1000000 == 0)
             {
-                session.Fiber().Debug($"benchmark count: {benchmarkServerComponent.Count} {TimeInfo.Instance.ClientNow()}");
+                Log.Debug($"benchmark count: {benchmarkServerComponent.Count} {TimeInfo.Instance.ClientNow()}");
             }
             await ETTask.CompletedTask;
         }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Realm/C2R_LoginHandler.cs

@@ -11,7 +11,7 @@ namespace ET.Server
 		{
 			// 随机分配一个Gate
 			StartSceneConfig config = RealmGateAddressHelper.GetGate(session.Zone(), request.Account);
-			session.Fiber().Debug($"gate address: {config}");
+			Log.Debug($"gate address: {config}");
 			
 			// 向gate请求一个key,客户端可以拿着这个key连接gate
 			G2R_GetLoginKey g2RGetLoginKey = (G2R_GetLoginKey) await session.Fiber().Root.GetComponent<MessageSender>().Call(

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/Console/CreateRobotConsoleHandler.cs

@@ -13,7 +13,7 @@ namespace ET.Server
             {
                 case ConsoleMode.CreateRobot:
                 {
-                    fiber.Console("CreateRobot args error!");
+                    Log.Console("CreateRobot args error!");
                     break;
                 }
                 default:
@@ -31,7 +31,7 @@ namespace ET.Server
                     for (int i = 0; i < options.Num; ++i)
                     {
                         await robotManagerComponent.NewRobot($"Robot_{i}");
-                        fiber.Console($"create robot {i}");
+                        Log.Console($"create robot {i}");
                         await timerComponent.WaitAsync(2000);
                     }
                     break;

+ 7 - 7
Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/RobotConsoleHandler.cs

@@ -20,13 +20,13 @@ namespace ET.Server
 
                     try
                     {
-                        fiber.Debug($"run case start: {caseType}");
+                        Log.Debug($"run case start: {caseType}");
                         await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Fiber = fiber, Content = content });
-                        fiber.Debug($"run case finish: {caseType}");
+                        Log.Debug($"run case finish: {caseType}");
                     }
                     catch (Exception e)
                     {
-                        fiber.Debug($"run case error: {caseType}\n{e}");
+                        Log.Debug($"run case error: {caseType}\n{e}");
                     }
                     break;
                 }
@@ -38,18 +38,18 @@ namespace ET.Server
                         int caseType = (int)fieldInfo.GetValue(null);
                         if (caseType > RobotCaseType.MaxCaseType)
                         {
-                            fiber.Debug($"case > {RobotCaseType.MaxCaseType}: {caseType}");
+                            Log.Debug($"case > {RobotCaseType.MaxCaseType}: {caseType}");
                             break;
                         }
                         try
                         {
-                            fiber.Debug($"run case start: {caseType}");
+                            Log.Debug($"run case start: {caseType}");
                             await EventSystem.Instance.Invoke<RobotInvokeArgs, ETTask>(caseType, new RobotInvokeArgs() { Fiber = fiber, Content = content});
-                            fiber.Debug($"---------run case finish: {caseType}");
+                            Log.Debug($"---------run case finish: {caseType}");
                         }
                         catch (Exception e)
                         {
-                            fiber.Debug($"run case error: {caseType}\n{e}");
+                            Log.Debug($"run case error: {caseType}\n{e}");
                             break;
                         }
                     }

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

@@ -10,7 +10,6 @@ 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 +20,20 @@ namespace ET.Server
 
             if (message.Frame < room.AuthorityFrame)  // 小于AuthorityFrame,丢弃
             {
-                fiber.Warning($"FrameMessage < AuthorityFrame discard: {message}");
+                Log.Warning($"FrameMessage < AuthorityFrame discard: {message}");
                 return;
             }
 
             if (message.Frame > room.AuthorityFrame + 10)  // 大于AuthorityFrame + 10,丢弃
             {
-                fiber.Warning($"FrameMessage > AuthorityFrame + 10 discard: {message}");
+                Log.Warning($"FrameMessage > AuthorityFrame + 10 discard: {message}");
                 return;
             }
             
             OneFrameInputs oneFrameInputs = frameBuffer.FrameInputs(message.Frame);
             if (oneFrameInputs == null)
             {
-                fiber.Error($"FrameMessageHandler get frame is null: {message.Frame}, max frame: {frameBuffer.MaxFrame}");
+                Log.Error($"FrameMessageHandler get frame is null: {message.Frame}, max frame: {frameBuffer.MaxFrame}");
                 return;
             }
             oneFrameInputs.Inputs[message.PlayerId] = message.Input;

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

@@ -75,12 +75,12 @@ namespace ET.Server
             // 检查
             if (aoiEntity.SeeUnits.Count > 1)
             {
-                fiber.Error($"aoiEntity has see units: {aoiEntity.SeeUnits.Count}");
+                Log.Error($"aoiEntity has see units: {aoiEntity.SeeUnits.Count}");
             }
 
             if (aoiEntity.BeSeeUnits.Count > 1)
             {
-                fiber.Error($"aoiEntity has beSee units: {aoiEntity.BeSeeUnits.Count}");
+                Log.Error($"aoiEntity has beSee units: {aoiEntity.BeSeeUnits.Count}");
             }
         }
 

+ 8 - 8
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs

@@ -39,7 +39,7 @@ namespace ET.Server
             using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
             {
                 self.locations[key] = instanceId;
-                self.Fiber().Info($"location add key: {key} instanceId: {instanceId}");
+                Log.Info($"location add key: {key} instanceId: {instanceId}");
             }
         }
 
@@ -49,7 +49,7 @@ namespace ET.Server
             using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
             {
                 self.locations.Remove(key);
-                self.Fiber().Info($"location remove key: {key}");
+                Log.Info($"location remove key: {key}");
             }
         }
 
@@ -61,7 +61,7 @@ namespace ET.Server
             LockInfo lockInfo = self.AddChild<LockInfo, ActorId, CoroutineLock>(actorId, coroutineLock);
             self.lockInfos.Add(key, lockInfo);
 
-            self.Fiber().Info($"location lock key: {key} instanceId: {actorId}");
+            Log.Info($"location lock key: {key} instanceId: {actorId}");
 
             if (time > 0)
             {
@@ -73,7 +73,7 @@ namespace ET.Server
                     {
                         return;
                     }
-                    self.Fiber().Info($"location timeout unlock key: {key} instanceId: {actorId} newInstanceId: {actorId}");
+                    Log.Info($"location timeout unlock key: {key} instanceId: {actorId} newInstanceId: {actorId}");
                     self.UnLock(key, actorId, actorId);
                 }
                 TimeWaitAsync().Coroutine();
@@ -84,17 +84,17 @@ namespace ET.Server
         {
             if (!self.lockInfos.TryGetValue(key, out LockInfo lockInfo))
             {
-                self.Fiber().Error($"location unlock not found key: {key} {oldActorId}");
+                Log.Error($"location unlock not found key: {key} {oldActorId}");
                 return;
             }
 
             if (oldActorId != lockInfo.LockActorId)
             {
-                self.Fiber().Error($"location unlock oldInstanceId is different: {key} {oldActorId}");
+                Log.Error($"location unlock oldInstanceId is different: {key} {oldActorId}");
                 return;
             }
 
-            self.Fiber().Info($"location unlock key: {key} instanceId: {oldActorId} newInstanceId: {newInstanceId}");
+            Log.Info($"location unlock key: {key} instanceId: {oldActorId} newInstanceId: {newInstanceId}");
 
             self.locations[key] = newInstanceId;
 
@@ -110,7 +110,7 @@ namespace ET.Server
             using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
             {
                 self.locations.TryGetValue(key, out ActorId actorId);
-                self.Fiber().Info($"location get key: {key} actorId: {actorId}");
+                Log.Info($"location get key: {key} actorId: {actorId}");
                 return actorId;
             }
         }

+ 4 - 4
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationProxyComponentSystem.cs

@@ -12,7 +12,7 @@ namespace ET.Server
         public static async ETTask Add(this LocationProxyComponent self, int type, long key, ActorId actorId)
         {
             Fiber fiber = self.Fiber();
-            fiber.Info($"location proxy add {key}, {actorId} {TimeInfo.Instance.ServerNow()}");
+            Log.Info($"location proxy add {key}, {actorId} {TimeInfo.Instance.ServerNow()}");
             await fiber.Root.GetComponent<MessageSender>().Call(GetLocationSceneId(key),
                 new ObjectAddRequest() { Type = type, Key = key, ActorId = actorId });
         }
@@ -20,7 +20,7 @@ namespace ET.Server
         public static async ETTask Lock(this LocationProxyComponent self, int type, long key, ActorId actorId, int time = 60000)
         {
             Fiber fiber = self.Fiber();
-            fiber.Info($"location proxy lock {key}, {actorId} {TimeInfo.Instance.ServerNow()}");
+            Log.Info($"location proxy lock {key}, {actorId} {TimeInfo.Instance.ServerNow()}");
             await fiber.Root.GetComponent<MessageSender>().Call(GetLocationSceneId(key),
                 new ObjectLockRequest() { Type = type, Key = key, ActorId = actorId, Time = time });
         }
@@ -28,7 +28,7 @@ namespace ET.Server
         public static async ETTask UnLock(this LocationProxyComponent self, int type, long key, ActorId oldActorId, ActorId newActorId)
         {
             Fiber fiber = self.Fiber();
-            fiber.Info($"location proxy unlock {key}, {newActorId} {TimeInfo.Instance.ServerNow()}");
+            Log.Info($"location proxy unlock {key}, {newActorId} {TimeInfo.Instance.ServerNow()}");
             await fiber.Root.GetComponent<MessageSender>().Call(GetLocationSceneId(key),
                 new ObjectUnLockRequest() { Type = type, Key = key, OldActorId = oldActorId, NewActorId = newActorId });
         }
@@ -36,7 +36,7 @@ namespace ET.Server
         public static async ETTask Remove(this LocationProxyComponent self, int type, long key)
         {
             Fiber fiber = self.Fiber();
-            fiber.Info($"location proxy add {key}, {TimeInfo.Instance.ServerNow()}");
+            Log.Info($"location proxy add {key}, {TimeInfo.Instance.ServerNow()}");
             await fiber.Root.GetComponent<MessageSender>().Call(GetLocationSceneId(key),
                 new ObjectRemoveRequest() { Type = type, Key = key });
         }

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

@@ -13,13 +13,13 @@ namespace ET.Server
             Fiber fiber = entity.Fiber();
             if (actorMessage is not Message message)
             {
-                fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
                 return;
             }
 
             if (entity is not E e)
             {
-                fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
+                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Message).FullName}");
                 return;
             }
             
@@ -55,13 +55,13 @@ namespace ET.Server
                 Fiber fiber = entity.Fiber();
                 if (actorMessage is not Request request)
                 {
-                    fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
+                    Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
                     return;
                 }
 
                 if (entity is not E ee)
                 {
-                    fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
+                    Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
                     return;
                 }
 

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

@@ -20,7 +20,7 @@ namespace ET.Server
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
+                    Log.Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }
@@ -257,7 +257,7 @@ namespace ET.Server
                         ++failTimes;
                         if (failTimes > 20)
                         {
-                            root.Fiber().Debug($"actor send message fail, actorid: {messageLocationSender.Id} {iRequest}");
+                            Log.Debug($"actor send message fail, actorid: {messageLocationSender.Id} {iRequest}");
                             messageLocationSender.Error = ErrorCore.ERR_NotFoundActor;
                             // 这里不能删除actor,要让后面等待发送的消息也返回ERR_NotFoundActor,直到超时删除
                             return response;

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

@@ -17,7 +17,7 @@ namespace ET.Server
         [EntitySystem]
         private static void Destroy(this MessageLocationSender self)
         {
-            self.Fiber().Debug($"actor location remove: {self.Id}");
+            Log.Debug($"actor location remove: {self.Id}");
             self.LastSendOrRecvTime = 0;
             self.ActorId = default;
             self.Error = 0;

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

@@ -131,7 +131,7 @@ namespace ET.Server
 		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
-			    fiber.Error($"save entity is null: {typeof (T).FullName}");
+			    Log.Error($"save entity is null: {typeof (T).FullName}");
 
 			    return;
 		    }
@@ -152,7 +152,7 @@ namespace ET.Server
 		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
-			    fiber.Error($"save entity is null: {typeof (T).FullName}");
+			    Log.Error($"save entity is null: {typeof (T).FullName}");
 
 			    return;
 		    }
@@ -173,7 +173,7 @@ namespace ET.Server
 		    Fiber fiber = self.Fiber();
 		    if (entities == null)
 		    {
-			    fiber.Error($"save entity is null");
+			    Log.Error($"save entity is null");
 			    return;
 		    }
 

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Server/Module/Http/HttpComponentSystem.cs

@@ -56,7 +56,7 @@ namespace ET.Server
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error(e);
+                    Log.Error(e);
                 }
             }
         }
@@ -70,7 +70,7 @@ namespace ET.Server
             }
             catch (Exception e)
             {
-                self.Fiber().Error(e);
+                Log.Error(e);
             }
             context.Request.InputStream.Dispose();
             context.Response.OutputStream.Dispose();

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/Message/ProcessOuterSenderSystem.cs

@@ -14,12 +14,12 @@ namespace ET.Server
             {
                 case NetworkProtocol.TCP:
                 {
-                    self.AService = new TService(address, ServiceType.Inner, self.Fiber().Log);
+                    self.AService = new TService(address, ServiceType.Inner);
                     break;
                 }
                 case NetworkProtocol.KCP:
                 {
-                    self.AService = new KService(address, ServiceType.Inner, self.Fiber().Log);
+                    self.AService = new KService(address, ServiceType.Inner);
                     break;
                 }
             }
@@ -235,7 +235,7 @@ namespace ET.Server
             long costTime = endTime - beginTime;
             if (costTime > 200)
             {
-                fiber.Warning($"actor rpc time > 200: {costTime} {iRequest}");
+                Log.Warning($"actor rpc time > 200: {costTime} {iRequest}");
             }
 
             return response;

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

@@ -9,15 +9,14 @@ 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)
             {
-                fiber.Error($"{robotCase.Zone()} {e}");
-                fiber.Console($"RobotCase Error {this.GetType().FullName}:\n\t{e}");
+                Log.Error($"{robotCase.Zone()} {e}");
+                Log.Console($"RobotCase Error {this.GetType().FullName}:\n\t{e}");
             }
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/Router/FiberInit_Router.cs

@@ -12,7 +12,7 @@ namespace ET.Server
             
             // 开发期间使用OuterIPPort,云服务器因为本机没有OuterIP,所以要改成InnerIPPort,然后在云防火墙中端口映射到InnerIPPort
             root.AddComponent<RouterComponent, IPEndPoint, string>(startSceneConfig.OuterIPPort, startSceneConfig.StartProcessConfig.InnerIP);
-            root.Fiber.Console($"Router create: {root.Fiber.Id}");
+            Log.Console($"Router create: {root.Fiber.Id}");
             await ETTask.CompletedTask;
         }
     }

+ 34 - 36
Unity/Assets/Scripts/Hotfix/Server/Module/Router/RouterComponentSystem.cs

@@ -76,7 +76,7 @@ namespace ET.Server
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error(e);
+                    Log.Error(e);
                 }
             }
         }
@@ -134,7 +134,7 @@ namespace ET.Server
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error(e);
+                    Log.Error(e);
                 }
             }
         }
@@ -147,7 +147,6 @@ namespace ET.Server
                 return;
             }
 
-            Fiber fiber = self.Fiber();
             // accept
             byte flag = self.Cache[0];
             switch (flag)
@@ -172,7 +171,7 @@ namespace ET.Server
                         self.ConnectIdNodes.TryGetValue(connectId, out routerNode);
                         if (routerNode == null)
                         {
-                            fiber.Info($"router create reconnect: {self.IPEndPoint} {realAddress} {connectId} {outerConn} {innerConn}");
+                            Log.Info($"router create reconnect: {self.IPEndPoint} {realAddress} {connectId} {outerConn} {innerConn}");
                             routerNode = self.New(realAddress, connectId, outerConn, innerConn, self.CloneAddress());
                             // self.OuterNodes 这里不能add,因为还没验证完成,要在RouterAck中加入
                         }
@@ -180,7 +179,7 @@ namespace ET.Server
 
                     if (routerNode.ConnectId != connectId)
                     {
-                        fiber.Warning($"kcp router router reconnect connectId diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
+                        Log.Warning($"kcp router router reconnect connectId diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
                         break;
                     }
                     
@@ -188,27 +187,27 @@ namespace ET.Server
                     // 这个路由连接不上,客户端会换个软路由,所以没关系
                     if (routerNode.InnerConn != innerConn)
                     {
-                        fiber.Warning($"kcp router router reconnect inner conn diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
+                        Log.Warning($"kcp router router reconnect inner conn diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
                         break;
                     }
                     
                     if (routerNode.OuterConn != outerConn)
                     {
-                        fiber.Warning($"kcp router router reconnect outer conn diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
+                        Log.Warning($"kcp router router reconnect outer conn diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
                         break;
                     }
 
                     // 校验ip,连接过程中ip不能变化
                     if (!Equals(routerNode.SyncIpEndPoint, self.IPEndPoint))
                     {
-                        fiber.Warning($"kcp router syn ip is diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
+                        Log.Warning($"kcp router syn ip is diff1: {routerNode.SyncIpEndPoint} {(IPEndPoint) self.IPEndPoint}");
                         break;
                     }
 
                     // 校验内网地址
                     if (routerNode.InnerAddress != realAddress)
                     {
-                        fiber.Warning($"router sync error2: {routerNode.OuterConn} {routerNode.InnerAddress} {outerConn} {realAddress}");
+                        Log.Warning($"router sync error2: {routerNode.OuterConn} {routerNode.InnerAddress} {outerConn} {realAddress}");
                         break;
                     }
                     
@@ -251,7 +250,7 @@ namespace ET.Server
                     {
                         outerConn = NetServices.Instance.CreateConnectChannelId();
                         routerNode = self.New(realAddress, connectId, outerConn, innerConn, self.CloneAddress());
-                        fiber.Info($"router create: {realAddress} {connectId} {outerConn} {innerConn} {routerNode.SyncIpEndPoint}");
+                        Log.Info($"router create: {realAddress} {connectId} {outerConn} {innerConn} {routerNode.SyncIpEndPoint}");
                         self.OuterNodes.Add(routerNode.OuterConn, routerNode);
                     }
 
@@ -264,14 +263,14 @@ namespace ET.Server
                     // 校验ip,连接过程中ip不能变化
                     if (!Equals(routerNode.SyncIpEndPoint, self.IPEndPoint))
                     {
-                        fiber.Warning($"kcp router syn ip is diff1: {routerNode.SyncIpEndPoint} {self.IPEndPoint}");
+                        Log.Warning($"kcp router syn ip is diff1: {routerNode.SyncIpEndPoint} {self.IPEndPoint}");
                         break;
                     }
 
                     // 校验内网地址
                     if (routerNode.InnerAddress != realAddress)
                     {
-                        fiber.Warning($"router sync error2: {routerNode.OuterConn} {routerNode.InnerAddress} {outerConn} {realAddress}");
+                        Log.Warning($"router sync error2: {routerNode.OuterConn} {routerNode.InnerAddress} {outerConn} {realAddress}");
                         break;
                     }
 
@@ -300,7 +299,7 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouter))
                     {
-                        fiber.Warning($"kcp router syn not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router syn not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
 
@@ -314,7 +313,7 @@ namespace ET.Server
                     IPEndPoint ipEndPoint = (IPEndPoint) self.IPEndPoint;
                     if (!Equals(kcpRouter.SyncIpEndPoint.Address, ipEndPoint.Address))
                     {
-                        fiber.Warning($"kcp router syn ip is diff3: {kcpRouter.SyncIpEndPoint.Address} {ipEndPoint.Address}");
+                        Log.Warning($"kcp router syn ip is diff3: {kcpRouter.SyncIpEndPoint.Address} {ipEndPoint.Address}");
                         break;
                     }
                     
@@ -329,7 +328,7 @@ namespace ET.Server
                     self.Cache.WriteTo(5, innerConn);
                     byte[] addressBytes = ipEndPoint.ToString().ToByteArray();
                     Array.Copy(addressBytes, 0, self.Cache, 9, addressBytes.Length);
-                    fiber.Info($"kcp router syn: {outerConn} {innerConn} {kcpRouter.InnerIpEndPoint} {kcpRouter.OuterIpEndPoint}");
+                    Log.Info($"kcp router syn: {outerConn} {innerConn} {kcpRouter.InnerIpEndPoint} {kcpRouter.OuterIpEndPoint}");
                     self.InnerSocket.SendTo(self.Cache, 0, 9 + addressBytes.Length, SocketFlags.None, kcpRouter.InnerIpEndPoint);
 
                     if (!kcpRouter.CheckOuterCount(timeNow))
@@ -352,19 +351,19 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouter))
                     {
-                        fiber.Warning($"kcp router outer fin not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router outer fin not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
 
                     // 比对innerConn
                     if (kcpRouter.InnerConn != innerConn)
                     {
-                        fiber.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouter.Status}");
+                        Log.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouter.Status}");
                         break;
                     }
 
                     kcpRouter.LastRecvOuterTime = timeNow;
-                    fiber.Info($"kcp router outer fin: {outerConn} {innerConn} {kcpRouter.InnerIpEndPoint}");
+                    Log.Info($"kcp router outer fin: {outerConn} {innerConn} {kcpRouter.InnerIpEndPoint}");
                     self.InnerSocket.SendTo(self.Cache, 0, messageLength, SocketFlags.None, kcpRouter.InnerIpEndPoint);
 
                     if (!kcpRouter.CheckOuterCount(timeNow))
@@ -388,20 +387,20 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouter))
                     {
-                        fiber.Warning($"kcp router msg not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router msg not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
 
                     if (kcpRouter.Status != RouterStatus.Msg)
                     {
-                        fiber.Warning($"router node status error: {innerConn} {outerConn} {kcpRouter.Status}");
+                        Log.Warning($"router node status error: {innerConn} {outerConn} {kcpRouter.Status}");
                         break;
                     }
 
                     // 比对innerConn
                     if (kcpRouter.InnerConn != innerConn)
                     {
-                        fiber.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouter.Status}");
+                        Log.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouter.Status}");
                         break;
                     }
 
@@ -435,7 +434,6 @@ namespace ET.Server
 
             // accept
             byte flag = self.Cache[0];
-            Fiber fiber = self.Fiber();
             switch (flag)
             {
                 case KcpProtocalType.RouterReconnectACK:
@@ -445,14 +443,14 @@ namespace ET.Server
                     uint connectId = BitConverter.ToUInt32(self.Cache, 9);
                     if (!self.ConnectIdNodes.TryGetValue(connectId, out RouterNode kcpRouterNode))
                     {
-                        fiber.Warning($"router node error: {innerConn} {connectId}");
+                        Log.Warning($"router node error: {innerConn} {connectId}");
                         break;
                     }
 
                     // 必须校验innerConn,防止伪造
                     if (innerConn != kcpRouterNode.InnerConn)
                     {
-                        fiber.Warning(
+                        Log.Warning(
                             $"router node innerConn error: {innerConn} {kcpRouterNode.InnerConn} {outerConn} {kcpRouterNode.OuterConn} {kcpRouterNode.Status}");
                         break;
                     }
@@ -460,7 +458,7 @@ namespace ET.Server
                     // 必须校验outerConn,防止伪造
                     if (outerConn != kcpRouterNode.OuterConn)
                     {
-                        fiber.Warning(
+                        Log.Warning(
                             $"router node outerConn error: {innerConn} {kcpRouterNode.InnerConn} {outerConn} {kcpRouterNode.OuterConn} {kcpRouterNode.Status}");
                         break;
                     }
@@ -480,7 +478,7 @@ namespace ET.Server
                     self.Cache.WriteTo(0, KcpProtocalType.RouterReconnectACK);
                     self.Cache.WriteTo(1, kcpRouterNode.InnerConn);
                     self.Cache.WriteTo(5, kcpRouterNode.OuterConn);
-                    fiber.Info($"kcp router RouterAck: {outerConn} {innerConn} {kcpRouterNode.SyncIpEndPoint}");
+                    Log.Info($"kcp router RouterAck: {outerConn} {innerConn} {kcpRouterNode.SyncIpEndPoint}");
                     self.OuterSocket.SendTo(self.Cache, 0, 9, SocketFlags.None, kcpRouterNode.SyncIpEndPoint);
                     break;
                 }
@@ -492,7 +490,7 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouterNode))
                     {
-                        fiber.Warning($"kcp router ack not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router ack not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
                     
@@ -502,7 +500,7 @@ namespace ET.Server
 
                     kcpRouterNode.LastRecvInnerTime = timeNow;
                     // 转发出去
-                    fiber.Info($"kcp router ack: {outerConn} {innerConn} {kcpRouterNode.OuterIpEndPoint}");
+                    Log.Info($"kcp router ack: {outerConn} {innerConn} {kcpRouterNode.OuterIpEndPoint}");
                     self.OuterSocket.SendTo(self.Cache, 0, messageLength, SocketFlags.None, kcpRouterNode.OuterIpEndPoint);
                     break;
                 }
@@ -519,14 +517,14 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouterNode))
                     {
-                        fiber.Warning($"kcp router inner fin not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router inner fin not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
 
                     // 比对innerConn
                     if (kcpRouterNode.InnerConn != innerConn)
                     {
-                        fiber.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouterNode.Status}");
+                        Log.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouterNode.Status}");
                         break;
                     }
 
@@ -537,7 +535,7 @@ namespace ET.Server
                     }
 
                     kcpRouterNode.LastRecvInnerTime = timeNow;
-                    fiber.Info($"kcp router inner fin: {outerConn} {innerConn} {kcpRouterNode.OuterIpEndPoint}");
+                    Log.Info($"kcp router inner fin: {outerConn} {innerConn} {kcpRouterNode.OuterIpEndPoint}");
                     self.OuterSocket.SendTo(self.Cache, 0, messageLength, SocketFlags.None, kcpRouterNode.OuterIpEndPoint);
 
                     break;
@@ -556,14 +554,14 @@ namespace ET.Server
 
                     if (!self.OuterNodes.TryGetValue(outerConn, out RouterNode kcpRouterNode))
                     {
-                        fiber.Warning($"kcp router inner msg not found outer nodes: {outerConn} {innerConn}");
+                        Log.Warning($"kcp router inner msg not found outer nodes: {outerConn} {innerConn}");
                         break;
                     }
 
                     // 比对innerConn
                     if (kcpRouterNode.InnerConn != innerConn)
                     {
-                        fiber.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouterNode.Status}");
+                        Log.Warning($"router node innerConn error: {innerConn} {outerConn} {kcpRouterNode.Status}");
                         break;
                     }
 
@@ -603,7 +601,7 @@ namespace ET.Server
 
             routerNode.Status = RouterStatus.Sync;
 
-            self.Fiber().Info($"router new: outerConn: {outerConn} innerConn: {innerConn} {syncEndPoint}");
+            Log.Info($"router new: outerConn: {outerConn} innerConn: {innerConn} {syncEndPoint}");
 
             return routerNode;
         }
@@ -616,7 +614,7 @@ namespace ET.Server
                 return;
             }
 
-            self.Fiber().Info($"router node remove: {routerNode.OuterConn} {routerNode.InnerConn} {error}");
+            Log.Info($"router node remove: {routerNode.OuterConn} {routerNode.InnerConn} {error}");
             self.Remove(id);
         }
 
@@ -639,7 +637,7 @@ namespace ET.Server
                 }
             }
 
-            self.Fiber().Info($"router remove: {routerNode.Id} outerConn: {routerNode.OuterConn} innerConn: {routerNode.InnerConn}");
+            Log.Info($"router remove: {routerNode.Id} outerConn: {routerNode.OuterConn} innerConn: {routerNode.InnerConn}");
 
             routerNode.Dispose();
         }

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

@@ -18,7 +18,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error($"move timer error: {self.Id}\n{e}");
+                    Log.Error($"move timer error: {self.Id}\n{e}");
                 }
             }
         }
@@ -57,7 +57,7 @@ namespace ET
 
                 if (aaiHandler == null)
                 {
-                    fiber.Error($"not found aihandler: {aiConfig.Name}");
+                    Log.Error($"not found aihandler: {aiConfig.Name}");
                     continue;
                 }
 

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

@@ -10,16 +10,15 @@ 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)
             {
-                fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
+                Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Message).Name}");
                 return;
             }
 
             if (entity is not E e)
             {
-                fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
+                Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).Name} --{typeof (Message).FullName}");
                 return;
             }
 
@@ -57,13 +56,13 @@ namespace ET
                 Fiber fiber = entity.Fiber();
                 if (actorMessage is not Request request)
                 {
-                    fiber.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
+                    Log.Error($"消息类型转换错误: {actorMessage.GetType().FullName} to {typeof (Request).Name}");
                     return;
                 }
 
                 if (entity is not E ee)
                 {
-                    fiber.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
+                    Log.Error($"Actor类型转换错误: {entity.GetType().FullName} to {typeof (E).FullName} --{typeof (Request).FullName}");
                     return;
                 }
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Console/ConsoleComponentSystem.cs

@@ -61,7 +61,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Console(e.ToString());
+                    Log.Console(e.ToString());
                 }
             }
         }

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Share/Module/Console/ReloadConfigConsoleHandler.cs

@@ -11,7 +11,7 @@ namespace ET
             {
                 case ConsoleMode.ReloadConfig:
                     contex.Parent.RemoveComponent<ModeContex>();
-                    fiber.Console("C must have config name, like: C UnitConfig");
+                    Log.Console("C must have config name, like: C UnitConfig");
                     break;
                 default:
                     string[] ss = content.Split(" ");
@@ -20,11 +20,11 @@ namespace ET
                     Type type = CodeTypes.Instance.GetType($"ET.{category}");
                     if (type == null)
                     {
-                        fiber.Console($"reload config but not find {category}");
+                        Log.Console($"reload config but not find {category}");
                         return;
                     }
                     await ConfigLoader.Instance.Reload(type);
-                    fiber.Console($"reload config {configName} finish!");
+                    Log.Console($"reload config {configName} finish!");
                     break;
             }
             

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Share/Module/Message/NetComponentSystem.cs

@@ -10,7 +10,7 @@ namespace ET
         [EntitySystem]
         private static void Awake(this NetComponent self, IPEndPoint address)
         {
-            self.AService = new TService(address, ServiceType.Outer, self.Fiber().Log);
+            self.AService = new KService(address, ServiceType.Outer);
             self.AService.AcceptCallback = self.OnAccept;
             self.AService.ReadCallback = self.OnRead;
             self.AService.ErrorCallback = self.OnError;
@@ -19,7 +19,7 @@ namespace ET
         [EntitySystem]
         private static void Awake(this NetComponent self, AddressFamily addressFamily)
         {
-            self.AService = new TService(addressFamily, ServiceType.Outer, self.Fiber().Log);
+            self.AService = new KService(addressFamily, ServiceType.Outer);
             self.AService.ReadCallback = self.OnRead;
             self.AService.ErrorCallback = self.OnError;
         }

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

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

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

@@ -17,7 +17,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    self.Fiber().Error($"session idle checker timer error: {self.Id}\n{e}");
+                    Log.Error($"session idle checker timer error: {self.Id}\n{e}");
                 }
             }
         }
@@ -46,7 +46,7 @@ namespace ET
                 return;
             }
 
-            self.Fiber().Info($"session timeout: {session.Id} {timeNow} {session.LastRecvTime} {session.LastSendTime} {timeNow - session.LastRecvTime} {timeNow - session.LastSendTime}");
+            Log.Info($"session timeout: {session.Id} {timeNow} {session.LastRecvTime} {session.LastSendTime} {timeNow - session.LastRecvTime} {timeNow - session.LastSendTime}");
             session.Error = ErrorCore.ERR_SessionSendOrRecvTimeout;
 
             session.Dispose();

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

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

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Recast/PathfindingComponentSystem.cs

@@ -43,7 +43,7 @@ namespace ET
         {
             if (self.navMesh == null)
             {
-                self.Fiber().Debug("寻路| Find 失败 pathfinding ptr is zero");
+                Log.Debug("寻路| Find 失败 pathfinding ptr is zero");
                 throw new Exception($"pathfinding ptr is zero: {self.Scene().Name}");
             }
 

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/Demo/Scene/SceneChangeStart_AddComponent.cs

@@ -24,7 +24,7 @@ namespace ET.Client
             }
             catch (Exception e)
             {
-                root.Fiber.Error(e);
+                Log.Error(e);
             }
 
         }

+ 1 - 2
Unity/Assets/Scripts/HotfixView/Client/Demo/UI/UIHelp/UIHelpEvent.cs

@@ -8,7 +8,6 @@ namespace ET.Client
     {
         public override async ETTask<UI> OnCreate(UIComponent uiComponent, UILayer uiLayer)
         {
-	        Fiber fiber = uiComponent.Fiber();
 	        try
 	        {
 		        string assetsName = $"Assets/Bundles/UI/Demo/{UIType.UIHelp}.prefab";
@@ -21,7 +20,7 @@ namespace ET.Client
 	        }
 	        catch (Exception e)
 	        {
-		        fiber.Error(e);
+		        Log.Error(e);
 		        return null;
 	        }
 		}

+ 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)
 			{
-				self.Fiber().Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
+				Log.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)
 			{
-				self.Fiber().Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
+				Log.Error($"motionSpeed数值异常, {motionSpeed}, 此动作跳过");
 				return;
 			}
 			self.MotionType = motionType;

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/LockStep/UI/UILSLobby/UILSLobbyComponentSystem.cs

@@ -34,7 +34,7 @@ namespace ET.Client
             byte[] bytes = File.ReadAllBytes(self.replayPath.text);
             
             Replay replay = MemoryPackHelper.Deserialize(typeof (Replay), bytes, 0, bytes.Length) as Replay;
-            self.Fiber().Debug($"start replay: {replay.Snapshots.Count} {replay.FrameInputs.Count} {replay.UnitInfos.Count}");
+            Log.Debug($"start replay: {replay.Snapshots.Count} {replay.FrameInputs.Count} {replay.UnitInfos.Count}");
             LSSceneChangeHelper.SceneChangeToReplay(self.Root(), replay).Coroutine();
         }
     }

+ 2 - 2
Unity/Assets/Scripts/Model/Share/LockStep/LSEntitySystemSingleton.cs

@@ -94,7 +94,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    entity.Fiber().Error(e);
+                    Log.Error(e);
                 }
             }
         }
@@ -120,7 +120,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    entity.Fiber().Error(e);
+                    Log.Error(e);
                 }
             }
         }

+ 2 - 3
Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionDispatcher.cs

@@ -66,12 +66,11 @@ namespace ET
 
         public void Handle(Session session, object message)
         {
-            Fiber fiber = session.Fiber();
             List<MessageSessionDispatcherInfo> actions;
             ushort opcode = OpcodeType.Instance.GetOpcode(message.GetType());
             if (!this.handlers.TryGetValue(opcode, out actions))
             {
-                fiber.Error($"消息没有处理: {opcode} {message}");
+                Log.Error($"消息没有处理: {opcode} {message}");
                 return;
             }
 
@@ -89,7 +88,7 @@ namespace ET
                 }
                 catch (Exception e)
                 {
-                    fiber.Error(e);
+                    Log.Error(e);
                 }
             }
         }

+ 4 - 5
Unity/Assets/Scripts/Model/Share/Module/Message/MessageSessionHandler.cs

@@ -16,13 +16,13 @@ namespace ET
             using Message msg = message as Message;
             if (message == null)
             {
-                session.Fiber().Error($"消息类型转换错误: {msg.GetType().FullName} to {typeof (Message).Name}");
+                Log.Error($"消息类型转换错误: {msg.GetType().FullName} to {typeof (Message).Name}");
                 return;
             }
 
             if (session.IsDisposed)
             {
-                session.Fiber().Error($"session disconnect {msg}");
+                Log.Error($"session disconnect {msg}");
                 return;
             }
 
@@ -64,7 +64,6 @@ namespace ET
                 long instanceId = session.InstanceId;
 
                 Response response = ObjectPool.Instance.Fetch<Response>();
-                Fiber fiber = session.Fiber();
                 try
                 {
                     await this.Run(session, request, response);
@@ -72,13 +71,13 @@ namespace ET
                 catch (RpcException exception)
                 {
                     // 这里不能返回堆栈给客户端
-                    fiber.Error(exception.ToString());
+                    Log.Error(exception.ToString());
                     response.Error = exception.Error;
                 }
                 catch (Exception exception)
                 {
                     // 这里不能返回堆栈给客户端
-                    fiber.Error(exception.ToString());
+                    Log.Error(exception.ToString());
                     response.Error = ErrorCore.ERR_RpcFail;
                 }
                 

+ 2 - 2
Unity/Assets/Scripts/Model/Share/Module/Message/Session.cs

@@ -31,7 +31,7 @@ namespace ET
 
             self.requestCallbacks.Clear();
             
-            self.Fiber().Info($"session create: zone: {self.Zone()} id: {self.Id} {timeNow} ");
+            Log.Info($"session create: zone: {self.Zone()} id: {self.Id} {timeNow} ");
         }
         
         [EntitySystem]
@@ -44,7 +44,7 @@ namespace ET
                 responseCallback.Tcs.SetException(new RpcException(self.Error, $"session dispose: {self.Id} {self.RemoteAddress}"));
             }
 
-            self.Fiber().Info($"session dispose: {self.RemoteAddress} id: {self.Id} ErrorCode: {self.Error}, please see ErrorCode.cs! {TimeInfo.Instance.ClientNow()}");
+            Log.Info($"session dispose: {self.RemoteAddress} id: {self.Id} ErrorCode: {self.Error}, please see ErrorCode.cs! {TimeInfo.Instance.ClientNow()}");
             
             self.requestCallbacks.Clear();
         }