Procházet zdrojové kódy

1.配置trace类型的log,trace log会打印堆栈
2.修复actorproxy未彻底删除报异常的问题

tanghai před 8 roky
rodič
revize
91bf02e2b3

+ 18 - 4
Server/App/NLog.config

@@ -8,8 +8,15 @@
 			fileName="${basedir}/../Logs/Log.txt"
 			deleteOldFileOnStartup="false"
 			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
-		<target name="all" type="ColoredConsole"
-			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}"/>
+	</targets>
+
+	<targets>
+		<target name="trace" xsi:type="File"
+			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Trace.txt"
+			deleteOldFileOnStartup="false"
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=3:skipFrames=0}" />
+		<target name="trace" type="ColoredConsole"
+				layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${message} ${newline} ${stacktrace:format=Raw:topFrames=3:skipFrames=0}" />
 	</targets>
 	
 	<targets>
@@ -17,6 +24,8 @@
 			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Debug.txt"
 			deleteOldFileOnStartup="false"
 			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
+		<target name="debug" type="ColoredConsole"
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
 	</targets>
 
 	<targets>
@@ -24,18 +33,23 @@
 			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Info.txt"
 			deleteOldFileOnStartup="false"
 			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
+		<target name="info" type="ColoredConsole"
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
 	</targets>
 	
 	<targets>
 		<target name="error" xsi:type="File"
 			fileName="${basedir}/../Logs/Log-${var:appType}-${var:appId}-Error.txt"
 			deleteOldFileOnStartup="false"
-			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message} ${stacktrace:format=Flat:topFrames=100:skipFrames=0}" />
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
+		<target name="info" type="ColoredConsole"
+			layout="${longdate} ${var:appTypeFormat} ${var:appIdFormat} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
 	</targets>
 	
 	<rules>
 		<logger name="*" minlevel="Trace" writeTo="all" />
-		<logger name="*" minlevel="Debug" writeTo="debug" />
+		<logger name="*" minlevel="Trace" maxlevel="Trace" writeTo="trace" />
+		<logger name="*" minlevel="Debug" maxlevel="Debug" writeTo="debug" />
 		<logger name="*" minlevel="Info" maxlevel="Info" writeTo="info" />
 		<logger name="*" minlevel="Error" writeTo="error" />
 	</rules>

+ 5 - 0
Server/Base/Log.cs

@@ -4,6 +4,11 @@
 	{
 		private static readonly ILog globalLog = new NLogAdapter();
 
+		public static void Trace(string message)
+		{
+			globalLog.Trace(message);
+		}
+
 		public static void Warning(string message)
 		{
 			globalLog.Warning(message);

+ 1 - 0
Server/Base/Logger/ILog.cs

@@ -2,6 +2,7 @@
 {
 	public interface ILog
 	{
+		void Trace(string message);
 		void Warning(string message);
 		void Info(string message);
 		void Debug(string message);

+ 5 - 0
Server/Base/Logger/NLogAdapter.cs

@@ -10,6 +10,11 @@ namespace Model
 		{
 		}
 
+		public void Trace(string message)
+		{
+			this.logger.Trace(this.Decorate(message));
+		}
+
 		public void Warning(string message)
 		{
 			this.logger.Warn(this.Decorate(message));

+ 1 - 0
Server/Model/Component/ActorProxyComponent.cs

@@ -85,6 +85,7 @@ namespace Model
 			{
 				return;
 			}
+			this.ActorProxys.Remove(id);
 			actorProxy.Dispose();
 		}
 	}

+ 4 - 4
Server/ThirdParty/ENet/ENet.vcxproj

@@ -74,7 +74,7 @@
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(SolutionDir)\Platform\;$(IncludePath)</IncludePath>
-    <OutDir>$(ProjectDir)..\..\..\netcoreapp2.0</OutDir>
+    <OutDir>$(ProjectDir)..\..\..\Bin</OutDir>
     <IntDir>$(ProjectDir)..\..\..\Temp</IntDir>
     <TargetExt>.dll</TargetExt>
     <TargetName>$(ProjectName)</TargetName>
@@ -84,17 +84,17 @@
     <TargetName>$(ProjectName)</TargetName>
     <LinkIncremental>true</LinkIncremental>
     <IncludePath>$(SolutionDir)\Platform\;$(IncludePath)</IncludePath>
-    <OutDir>$(ProjectDir)..\..\..\netcoreapp2.0</OutDir>
+    <OutDir>$(ProjectDir)..\..\..\Bin</OutDir>
     <IntDir>$(ProjectDir)..\..\..\Temp\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
-    <OutDir>$(ProjectDir)..\..\..\netcoreapp2.0</OutDir>
+    <OutDir>$(ProjectDir)..\..\..\Bin</OutDir>
     <IntDir>$(ProjectDir)..\..\..\Temp</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
     <LinkIncremental>false</LinkIncremental>
-    <OutDir>$(ProjectDir)..\..\..\netcoreapp2.0</OutDir>
+    <OutDir>$(ProjectDir)..\..\..\Bin</OutDir>
     <IntDir>$(ProjectDir)..\..\..\Temp</IntDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">

+ 4 - 5
Unity/Assets/Scripts/Base/Log.cs

@@ -1,4 +1,7 @@
-namespace Model
+using System.Diagnostics;
+using ILRuntime.Runtime;
+
+namespace Model
 {
 	public static class Log
 	{
@@ -21,9 +24,5 @@
 		{
 			UnityEngine.Debug.Log(msg);
 		}
-		
-		public static void Flush()
-		{
-		}
 	}
 }