diff --git a/Ink Canvas/Helpers/LogHelper.cs b/Ink Canvas/Helpers/LogHelper.cs index 0e1129b2..a2c6ce66 100644 --- a/Ink Canvas/Helpers/LogHelper.cs +++ b/Ink Canvas/Helpers/LogHelper.cs @@ -1,5 +1,7 @@ using System; +using System.Diagnostics; using System.IO; +using System.Threading; namespace Ink_Canvas.Helpers { @@ -14,24 +16,19 @@ namespace Ink_Canvas.Helpers public static void NewLog(Exception ex) { - + if (ex == null) return; + var stackTrace = ex.StackTrace ?? ""; + var msg = $"[Exception] Type: {ex.GetType().FullName}\nMessage: {ex.Message}\nStackTrace: {stackTrace}"; + if (ex.InnerException != null) + { + msg += $"\nInnerException: {ex.InnerException.GetType().FullName} - {ex.InnerException.Message}\n{ex.InnerException.StackTrace}"; + } + WriteLogToFile(msg, LogType.Error); } public static void WriteLogToFile(string str, LogType logType = LogType.Info) { - string strLogType = "Info"; - switch (logType) - { - case LogType.Event: - strLogType = "Event"; - break; - case LogType.Trace: - strLogType = "Trace"; - break; - case LogType.Error: - strLogType = "Error"; - break; - } + string strLogType = logType.ToString(); try { var file = App.RootPath + LogFile; @@ -39,16 +36,30 @@ namespace Ink_Canvas.Helpers { Directory.CreateDirectory(App.RootPath); } - StreamWriter sw = new StreamWriter(file, true); - sw.WriteLine(string.Format("{0} [{1}] {2}", DateTime.Now.ToString("O"), strLogType, str)); - sw.Close(); + var threadId = Thread.CurrentThread.ManagedThreadId; + var callingMethod = new StackTrace(2, true).GetFrame(0); + string callerInfo = ""; + if (callingMethod != null) + { + var method = callingMethod.GetMethod(); + if (method != null) + { + var className = method.DeclaringType != null ? method.DeclaringType.FullName : ""; + callerInfo = $"{className}.{method.Name}"; + } + } + string logLine = string.Format("{0} [T{1}] [{2}] [{3}] {4}", DateTime.Now.ToString("O"), threadId, strLogType, callerInfo, str); + using (StreamWriter sw = new StreamWriter(file, true)) + { + sw.WriteLine(logLine); + } } catch { } } internal static void WriteLogToFile(string v, object warning) { - throw new NotImplementedException(); + WriteLogToFile($"[Warning] {v}", LogType.Warning); } public enum LogType diff --git a/Ink Canvas/Windows/RandWindow.xaml b/Ink Canvas/Windows/RandWindow.xaml index 62dddffb..253d13d4 100644 --- a/Ink Canvas/Windows/RandWindow.xaml +++ b/Ink Canvas/Windows/RandWindow.xaml @@ -106,7 +106,7 @@ - + diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index b061c064..631af792 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -207,8 +207,20 @@ namespace Ink_Canvas { Close(); } + private bool isIslandCallerFirstClick = true; + private void BorderBtnIslandCaller_MouseUp(object sender, MouseButtonEventArgs e) { + if (isIslandCallerFirstClick) + { + MessageBox.Show( + "首次使用ClassIsland点名功能,请确保已安装ClassIsland和Island caller插件。\n" + + "如未安装,请前往官网下载并安装后再使用。", + "提示", MessageBoxButton.OK, MessageBoxImage.Information); + isIslandCallerFirstClick = false; + return; + } + try { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache index ef098d71..f9524d04 100644 Binary files a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache and b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.csproj.AssemblyReference.cache differ diff --git a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources index 096bb1e4..04f1ddd7 100644 Binary files a/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources and b/Ink Canvas/obj/Debug/net472/InkCanvasForClass.g.resources differ diff --git a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs index bc5d3198..75a000f4 100644 --- a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs +++ b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "695B3561F1F2C3284724BFAA9122C85C2EF5221A" +#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A29F1514A9DC6332F074303F230464CD5C24A898" //------------------------------------------------------------------------------ // // 此代码由工具生成。 diff --git a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs index bc5d3198..75a000f4 100644 --- a/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs +++ b/Ink Canvas/obj/Debug/net472/Windows/RandWindow.g.i.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "695B3561F1F2C3284724BFAA9122C85C2EF5221A" +#pragma checksum "..\..\..\..\Windows\RandWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A29F1514A9DC6332F074303F230464CD5C24A898" //------------------------------------------------------------------------------ // // 此代码由工具生成。