Эх сурвалжийг харах

重新设置了日志格式,所有日志打印文件名和行号,Error日志还会打出堆栈

tanghai 9 жил өмнө
parent
commit
425b320e82

+ 15 - 5
Server/App/NLog.config

@@ -5,25 +5,35 @@
 	<variable name="appId" value="" />
 	<targets>
 		<target name="all" xsi:type="File"
-			fileName="${basedir}/Logs/Log-All.txt"
+			fileName="${basedir}/Logs/Log.txt"
 			deleteOldFileOnStartup="false"
-			layout="${longdate} ${var:appType} ${var:appId} ${message}" />
+		layout="${longdate} ${var:appType} ${var:appId} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
 	</targets>
 	<targets>
 		<target name="debug" xsi:type="File"
 			fileName="${basedir}/Logs/Log-${var:appType}-${var:appId}-Debug.txt"
-			deleteOldFileOnStartup="true"
-			layout="${longdate} ${var:appType} ${var:appId} ${message}" />
+			deleteOldFileOnStartup="false"
+			layout="${longdate} ${var:appType} ${var:appId} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message}" />
+	</targets>
+
+	<targets>
+		<target name="info" xsi:type="File"
+			fileName="${basedir}/Logs/Log-${var:appType}-${var:appId}-Info.txt"
+			deleteOldFileOnStartup="false"
+			layout="${longdate} ${var:appType} ${var:appId} ${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:appType} ${var:appId} ${message}" />
+			layout="${longdate} ${var:appType} ${var:appId} ${callsite:className=false:methodName=false:fileName=true:includeSourcePath=false:skipFrames=2} ${message} ${stacktrace:format=Flat:topFrames=100:skipFrames=2}" />
 	</targets>
+	
 	<rules>
 		<logger name="*" minlevel="Trace" writeTo="all" />
 		<logger name="*" minlevel="Debug" writeTo="debug" />
+		<logger name="*" minlevel="Info" maxlevel="Info" writeTo="info" />
 		<logger name="*" minlevel="Error" writeTo="error" />
 	</rules>
 </nlog>

+ 2 - 1
Server/App/Program.cs

@@ -19,8 +19,9 @@ namespace App
 				Object.ObjectManager.Register("Controller", DllHelper.GetController());
 
 				StartConfig startConfig = Game.Scene.AddComponent<StartConfigComponent, string[]>(args).MyConfig;
+
 				LogManager.Configuration.Variables["appType"] = startConfig.Options.AppType;
-				LogManager.Configuration.Variables["appId"] = startConfig.Options.Id.ToString("D4");
+				LogManager.Configuration.Variables["appId"] = startConfig.Options.Id.ToString();
 
 				Log.Info("server start........................");
 

+ 4 - 4
Server/Base/Logger/NLogAdapter.cs

@@ -12,22 +12,22 @@ namespace Base
 
 		public void Warning(string message)
 		{
-			this.logger.Warn(this.Decorate(SEP + message));
+			this.logger.Warn(this.Decorate(message));
 		}
 
 		public void Info(string message)
 		{
-			this.logger.Info(this.Decorate(SEP + message));
+			this.logger.Info(this.Decorate(message));
 		}
 
 		public void Debug(string message)
 		{
-			this.logger.Debug(this.Decorate(SEP + message));
+			this.logger.Debug(this.Decorate(message));
 		}
 
 		public void Error(string message)
 		{
-			this.logger.Error(this.Decorate(SEP + message));
+			this.logger.Error(this.Decorate(message));
 		}
 	}
 }

+ 1 - 1
Server/Model/Component/AppManagerComponent.cs

@@ -39,7 +39,7 @@ namespace Model
 
 #if __MonoCS__
 				const string exe = @"mono";
-				string arguments = $"App.exe --id={startConfig.Options.Id} --appType={startConfig.Options.AppType}";
+				string arguments = $"--debug App.exe --id={startConfig.Options.Id} --appType={startConfig.Options.AppType}";
 #else
 				const string exe = @"App.exe";
 				string arguments = $"--id={startConfig.Options.Id} --appType={startConfig.Options.AppType}";

+ 1 - 1
Server/Run.sh

@@ -6,4 +6,4 @@ cmake ../..
 make
 
 pkill App.exe
-mono App.exe --id=1 --appType=Manager
+mono --debug App.exe --id=1 --appType=Manager

+ 1 - 1
Server/Start.sh

@@ -2,4 +2,4 @@
 
 cd Bin/Debug/
 pkill App.exe
-mono App.exe --id=1 --appType=Manager
+mono --debug App.exe --id=1 --appType=Manager

+ 5 - 4
Unity/Assets/Editor/RsyncEditor/RsyncEditor.cs

@@ -42,10 +42,6 @@ namespace MyEditor
 			rsyncConfig.Password = EditorGUILayout.TextField("密码", rsyncConfig.Password);
 			rsyncConfig.RelativePath = EditorGUILayout.TextField("相对路径", rsyncConfig.RelativePath);
 
-			if (GUILayout.Button("添加排除项目"))
-			{
-				this.rsyncConfig.Exclude.Add("");
-			}
 			this.isFold = EditorGUILayout.Foldout(isFold, $"排除列表:");
 
 			if (!this.isFold)
@@ -63,6 +59,11 @@ namespace MyEditor
 				}
 			}
 
+			if (GUILayout.Button("添加排除项目"))
+			{
+				this.rsyncConfig.Exclude.Add("");
+			}
+
 			if (GUILayout.Button("保存"))
 			{
 				File.WriteAllText(ConfigFile, MongoHelper.ToJson(this.rsyncConfig));