diff --git a/Server/Model/Base/Logger/ALogDecorater.cs b/Server/Model/Base/Logger/ALogDecorater.cs deleted file mode 100644 index 298f2c1c39071af73247314044bcb3324efabf70..0000000000000000000000000000000000000000 --- a/Server/Model/Base/Logger/ALogDecorater.cs +++ /dev/null @@ -1,40 +0,0 @@ -namespace ETModel -{ - public abstract class ALogDecorater - { - protected const string SEP = " "; - private int level; - protected readonly ALogDecorater decorater; - - protected ALogDecorater(ALogDecorater decorater = null) - { - this.decorater = decorater; - this.Level = 0; - } - - protected int Level - { - get - { - return this.level; - } - set - { - this.level = value; - if (this.decorater != null) - { - this.decorater.Level = value + 1; - } - } - } - - public virtual string Decorate(string message) - { - if (this.decorater == null) - { - return message; - } - return this.decorater.Decorate(message); - } - } -} \ No newline at end of file diff --git a/Server/Model/Base/Logger/ILog.cs b/Server/Model/Base/Logger/ILog.cs index 20a5f364075e0938290e19e6eed37fa53d148b27..8d5d9fce9a8f6a0079c7867e30174c7c13389759 100644 --- a/Server/Model/Base/Logger/ILog.cs +++ b/Server/Model/Base/Logger/ILog.cs @@ -8,5 +8,11 @@ void Debug(string message); void Error(string message); void Fatal(string message); + void Trace(string message, params object[] args); + void Warning(string message, params object[] args); + void Info(string message, params object[] args); + void Debug(string message, params object[] args); + void Error(string message, params object[] args); + void Fatal(string message, params object[] args); } } \ No newline at end of file diff --git a/Server/Model/Base/Logger/NLogAdapter.cs b/Server/Model/Base/Logger/NLogAdapter.cs index 099a3a21ca632683f31f5d597741c44ebe672b83..3c411e95bf13fa0841acf4dcf3253c7d53a9a289 100644 --- a/Server/Model/Base/Logger/NLogAdapter.cs +++ b/Server/Model/Base/Logger/NLogAdapter.cs @@ -2,42 +2,68 @@ namespace ETModel { - public class NLogAdapter: ALogDecorater, ILog + public class NLogAdapter: ILog { private readonly Logger logger = LogManager.GetLogger("Logger"); - public NLogAdapter(ALogDecorater decorater = null): base(decorater) - { - } - public void Trace(string message) { - this.logger.Trace(this.Decorate(message)); + this.logger.Trace(message); } public void Warning(string message) { - this.logger.Warn(this.Decorate(message)); + this.logger.Warn(message); } public void Info(string message) { - this.logger.Info(this.Decorate(message)); + this.logger.Info(message); } public void Debug(string message) { - this.logger.Debug(this.Decorate(message)); + this.logger.Debug(message); } public void Error(string message) { - this.logger.Error(this.Decorate(message)); + this.logger.Error(message); } public void Fatal(string message) { - this.logger.Fatal(this.Decorate(message)); + this.logger.Fatal(message); } - } + + public void Trace(string message, params object[] args) + { + this.logger.Trace(message, args); + } + + public void Warning(string message, params object[] args) + { + this.logger.Warn(message, args); + } + + public void Info(string message, params object[] args) + { + this.logger.Info(message, args); + } + + public void Debug(string message, params object[] args) + { + this.logger.Debug(message, args); + } + + public void Error(string message, params object[] args) + { + this.logger.Error(message, args); + } + + public void Fatal(string message, params object[] args) + { + this.logger.Fatal(message, args); + } + } } \ No newline at end of file diff --git a/Server/Model/Base/Logger/StackInfoDecorater.cs b/Server/Model/Base/Logger/StackInfoDecorater.cs deleted file mode 100644 index 53366a944733d8710171892c42b4a742b5495c54..0000000000000000000000000000000000000000 --- a/Server/Model/Base/Logger/StackInfoDecorater.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System.Diagnostics; -using System.IO; - -namespace ETModel -{ - internal class StackInfoDecorater: ALogDecorater - { - public StackInfoDecorater(ALogDecorater decorater = null): base(decorater) - { - this.FileName = true; - this.FileLineNumber = true; - } - - public bool FileName { get; set; } - - public bool FileLineNumber { get; set; } - - public override string Decorate(string message) - { - if (this.decorater != null) - { - message = this.decorater.Decorate(message); - } - - if (!this.FileLineNumber && !this.FileName) - { - return message; - } - - string extraInfo = ""; - StackTrace stackTrace = new StackTrace(true); - StackFrame frame = stackTrace.GetFrame(this.Level + 3); - - if (this.FileName) - { - string fileName = Path.GetFileName(frame.GetFileName()); - extraInfo += fileName + " "; - } - if (this.FileLineNumber) - { - int fileLineNumber = frame.GetFileLineNumber(); - extraInfo += fileLineNumber + " "; - } - return extraInfo + message; - } - } -} \ No newline at end of file diff --git a/Unity/Assets/Hotfix/Base/Log.cs b/Unity/Assets/Hotfix/Base/Log.cs index f83688c2330309d870da3f0f2d3c8e16533d98a8..bab704eec25add8486929bc2de5ea0845dce56c0 100644 --- a/Unity/Assets/Hotfix/Base/Log.cs +++ b/Unity/Assets/Hotfix/Base/Log.cs @@ -4,6 +4,11 @@ namespace ETHotfix { public static class Log { + public static void Trace(string msg) + { + ETModel.Log.Trace(msg); + } + public static void Warning(string msg) { ETModel.Log.Warning(msg); @@ -29,9 +34,38 @@ namespace ETHotfix ETModel.Log.Debug(msg); } + public static void Trace(string message, params object[] args) + { + ETModel.Log.Trace(message, args); + } + + public static void Warning(string message, params object[] args) + { + ETModel.Log.Warning(message, args); + } + + public static void Info(string message, params object[] args) + { + ETModel.Log.Info(message, args); + } + + public static void Debug(string message, params object[] args) + { + ETModel.Log.Debug(message, args); + } + + public static void Error(string message, params object[] args) + { + ETModel.Log.Error(message, args); + } + + public static void Fatal(string message, params object[] args) + { + ETModel.Log.Fatal(message, args); + } + public static void Msg(object msg) { - Debug(Dumper.DumpAsString(msg)); } } diff --git a/Unity/Assets/Model/Base/Log.cs b/Unity/Assets/Model/Base/Log.cs index 64e0c2accb63cbf081657da406208db9a464704e..c1455150fcd0cbe3a50b53cada8c6ccb01f5906d 100644 --- a/Unity/Assets/Model/Base/Log.cs +++ b/Unity/Assets/Model/Base/Log.cs @@ -8,30 +8,65 @@ namespace ETModel { UnityEngine.Debug.Log(msg); } - - public static void Warning(string msg) + + public static void Debug(string msg) { - UnityEngine.Debug.LogWarning(msg); + UnityEngine.Debug.Log(msg); } - + public static void Info(string msg) { UnityEngine.Debug.Log(msg); } - public static void Error(Exception e) + public static void Warning(string msg) { - UnityEngine.Debug.LogError(e.ToString()); + UnityEngine.Debug.LogWarning(msg); } public static void Error(string msg) { UnityEngine.Debug.LogError(msg); } + + public static void Error(Exception e) + { + UnityEngine.Debug.LogException(e); + } - public static void Debug(string msg) + public static void Fatal(string msg) { - UnityEngine.Debug.Log(msg); + UnityEngine.Debug.LogAssertion(msg); + } + + public static void Trace(string message, params object[] args) + { + UnityEngine.Debug.LogFormat(message, args); + } + + public static void Warning(string message, params object[] args) + { + UnityEngine.Debug.LogWarningFormat(message, args); + } + + public static void Info(string message, params object[] args) + { + UnityEngine.Debug.LogFormat(message, args); + } + + public static void Debug(string message, params object[] args) + { + UnityEngine.Debug.LogFormat(message, args); + } + + public static void Error(string message, params object[] args) + { + UnityEngine.Debug.LogErrorFormat(message, args); + } + + public static void Fatal(string message, params object[] args) + { + UnityEngine.Debug.LogAssertionFormat(message, args); } public static void Msg(object msg) diff --git a/Unity/Unity.sln b/Unity/Unity.sln index 8a9d5c5e83cc955e4842cbfdf179d6ee255d1d33..692fdca9e2f38aac542b439d8dc4dd33cad7cf50 100644 --- a/Unity/Unity.sln +++ b/Unity/Unity.sln @@ -4,10 +4,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Model", "Unity.Model. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.ThirdParty", "Unity.ThirdParty.csproj", "{E15BADD2-3A26-309A-AB0F-DC5B08044350}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Editor", "Unity.Editor.csproj", "{CD311104-1830-B119-81B6-5DBEE2467FFB}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Hotfix", "Unity.Hotfix.csproj", "{1066F652-6A89-D1C4-9881-1A19DF7AB80E}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Editor", "Unity.Editor.csproj", "{CD311104-1830-B119-81B6-5DBEE2467FFB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,14 +22,14 @@ Global {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Debug|Any CPU.Build.0 = Debug|Any CPU {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Release|Any CPU.ActiveCfg = Release|Any CPU {E15BADD2-3A26-309A-AB0F-DC5B08044350}.Release|Any CPU.Build.0 = Release|Any CPU - {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.Build.0 = Release|Any CPU {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Debug|Any CPU.Build.0 = Debug|Any CPU {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.ActiveCfg = Release|Any CPU {1066F652-6A89-D1C4-9881-1A19DF7AB80E}.Release|Any CPU.Build.0 = Release|Any CPU + {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD311104-1830-B119-81B6-5DBEE2467FFB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD311104-1830-B119-81B6-5DBEE2467FFB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE