Skip to content

Commit

Permalink
💾 Feat: Merge pull request #141 from Crequency/main
Browse files Browse the repository at this point in the history
[Pull Request] 日志系统及设置UI大改
  • Loading branch information
Dynesshely authored Sep 26, 2022
2 parents 80db6d2 + 6f76a5f commit c2ff106
Show file tree
Hide file tree
Showing 17 changed files with 415 additions and 5 deletions.
8 changes: 6 additions & 2 deletions KitX Dashboard/Data/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Serilog.Events;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace KitX_Dashboard.Data
Expand Down Expand Up @@ -235,7 +236,7 @@ public class Config_Log
{

[JsonInclude]
public long LogFileSingleMaxSize { get; set; } = 1024 * 10000; // 10MB
public long LogFileSingleMaxSize { get; set; } = 1024 * 1024 * 10; // 10MB

[JsonInclude]
public string LogFilePath { get; set; } = "./Log/";
Expand All @@ -249,6 +250,9 @@ public class Config_Log

[JsonInclude]
public int LogFileFlushInterval { get; set; } = 30;

[JsonInclude]
public LogEventLevel LogLevel { get; set; } = LogEventLevel.Information;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion KitX Dashboard/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void StartUpCheck()
fileSizeLimitBytes: Program.Config.Log.LogFileSingleMaxSize,
buffered: true,
flushToDiskInterval: new(0, 0, Program.Config.Log.LogFileFlushInterval),
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Information,
restrictedToMinimumLevel: Program.Config.Log.LogLevel,
rollOnFileSizeLimit: true,
retainedFileCountLimit: Program.Config.Log.LogFileMaxCount
)
Expand Down
16 changes: 16 additions & 0 deletions KitX Dashboard/Languages/en-us.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<x:String x:Key="Text_Public_Export">Export</x:String>
<x:String x:Key="Text_Public_Exit">Exit</x:String>
<x:String x:Key="Text_Public_ShowMainWindow">Show Main Window</x:String>
<x:String x:Key="Text_Public_Second">s</x:String>


<x:String x:Key="Text_Log_Verbose">Verbose</x:String>
<x:String x:Key="Text_Log_Debug">Debug</x:String>
<x:String x:Key="Text_Log_Information">Infomation</x:String>
<x:String x:Key="Text_Log_Warning">Warning</x:String>
<x:String x:Key="Text_Log_Error">Error</x:String>
<x:String x:Key="Text_Log_Fatal">Fatal</x:String>


<!--GreetingStart-->
Expand Down Expand Up @@ -139,6 +148,13 @@
<x:String x:Key="Text_Settings_Tab_Performence_Web_Port">Port</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Web_MyIP_Filter">Native IP Filter</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Greeting_Interval">Greeting Text Update Interval</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileSize">Log File Max Size</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileMaxCount">Log File Max Count</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileFlushInterval">Log File Flush Interval</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileLevel">Log Level</x:String>


<x:String x:Key="Text_Settings_Tab_Update">Update</x:String>


<x:String x:Key="Text_Settings_Tab_About">About</x:String>
Expand Down
16 changes: 16 additions & 0 deletions KitX Dashboard/Languages/ja-jp.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<x:String x:Key="Text_Public_Export">書き出す</x:String>
<x:String x:Key="Text_Public_Exit">終了する</x:String>
<x:String x:Key="Text_Public_ShowMainWindow">メインウィンドウを表示</x:String>
<x:String x:Key="Text_Public_Second">2番目</x:String>


<x:String x:Key="Text_Log_Verbose">详细</x:String>
<x:String x:Key="Text_Log_Debug">调试</x:String>
<x:String x:Key="Text_Log_Information">情報</x:String>
<x:String x:Key="Text_Log_Warning">警告</x:String>
<x:String x:Key="Text_Log_Error">エラー</x:String>
<x:String x:Key="Text_Log_Fatal">崩壊</x:String>


<!--GreetingStart-->
Expand Down Expand Up @@ -139,6 +148,13 @@
<x:String x:Key="Text_Settings_Tab_Performence_Web_Port">ポート</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Web_MyIP_Filter">ネイティブ IP フィルタリング ルール</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Greeting_Interval">あいさつ更新が遅れる</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileSize">ログ ファイルのサイズ制限</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileMaxCount">ログ ファイルの制限</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileFlushInterval">ログ ファイル キャッシュの遅延</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileLevel">ログレベル</x:String>


<x:String x:Key="Text_Settings_Tab_Update">更新する</x:String>


<x:String x:Key="Text_Settings_Tab_About">約</x:String>
Expand Down
16 changes: 16 additions & 0 deletions KitX Dashboard/Languages/zh-cn.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<x:String x:Key="Text_Public_Export">导出</x:String>
<x:String x:Key="Text_Public_Exit">退出</x:String>
<x:String x:Key="Text_Public_ShowMainWindow">显示主窗口</x:String>
<x:String x:Key="Text_Public_Second">秒</x:String>


<x:String x:Key="Text_Log_Verbose">详细</x:String>
<x:String x:Key="Text_Log_Debug">调试</x:String>
<x:String x:Key="Text_Log_Information">信息</x:String>
<x:String x:Key="Text_Log_Warning">警告</x:String>
<x:String x:Key="Text_Log_Error">错误</x:String>
<x:String x:Key="Text_Log_Fatal">崩溃</x:String>


<!--GreetingStart-->
Expand Down Expand Up @@ -139,6 +148,13 @@
<x:String x:Key="Text_Settings_Tab_Performence_Web_Port">端口</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Web_MyIP_Filter">本机IP过滤规则</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Greeting_Interval">招呼语更新延迟</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileSize">日志文件体积限制</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileMaxCount">日志文件数量限制</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileFlushInterval">日志文件缓存延时</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileLevel">日志等级</x:String>


<x:String x:Key="Text_Settings_Tab_Update">更新</x:String>


<x:String x:Key="Text_Settings_Tab_About">关于</x:String>
Expand Down
16 changes: 16 additions & 0 deletions KitX Dashboard/Languages/zh-cnt.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
<x:String x:Key="Text_Public_Export">導出</x:String>
<x:String x:Key="Text_Public_Exit">退出</x:String>
<x:String x:Key="Text_Public_ShowMainWindow">顯示主窗口</x:String>
<x:String x:Key="Text_Public_Second">秒</x:String>


<x:String x:Key="Text_Log_Verbose">詳細</x:String>
<x:String x:Key="Text_Log_Debug">調試</x:String>
<x:String x:Key="Text_Log_Information">信息</x:String>
<x:String x:Key="Text_Log_Warning">警告</x:String>
<x:String x:Key="Text_Log_Error">錯誤</x:String>
<x:String x:Key="Text_Log_Fatal">崩潰</x:String>


<!--GreetingStart-->
Expand Down Expand Up @@ -139,6 +148,13 @@
<x:String x:Key="Text_Settings_Tab_Performence_Web_Port">端口</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Web_MyIP_Filter">本機IP過濾器</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_Greeting_Interval">招呼語更新延遲</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileSize">日志文檔大小限制</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileMaxCount">日志文檔數量限制</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileFlushInterval">日志文檔緩衝延時</x:String>
<x:String x:Key="Text_Settings_Tab_Performence_LogFileLevel">日志級別</x:String>


<x:String x:Key="Text_Settings_Tab_Update">更新</x:String>


<x:String x:Key="Text_Settings_Tab_About">關於</x:String>
Expand Down
8 changes: 8 additions & 0 deletions KitX Dashboard/Models/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ internal static class EventHandlers

internal delegate void DevelopSettingsChangedHandler();

internal delegate void LogConfigUpdatedHandler();

internal static event LanguageChangedHandler? LanguageChanged;

internal static event GreetingTextIntervalUpdatedHandler? GreetingTextIntervalUpdated;
Expand All @@ -29,6 +31,8 @@ internal static class EventHandlers

internal static event DevelopSettingsChangedHandler? DevelopSettingsChanged;

internal static event LogConfigUpdatedHandler? LogConfigUpdated;


/// <summary>
/// 必要的初始化
Expand All @@ -41,6 +45,7 @@ internal static void Init()
MicaOpacityChanged += () => { };
PluginsListChanged += () => { };
DevelopSettingsChanged += () => { };
LogConfigUpdated += () => { };
}

/// <summary>
Expand Down Expand Up @@ -69,6 +74,9 @@ internal static void Invoke(string eventName)
case nameof(DevelopSettingsChanged):
DevelopSettingsChanged();
break;
case nameof(LogConfigUpdated):
LogConfigUpdated();
break;
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions KitX Dashboard/Models/SurpportLogLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Serilog.Events;

namespace KitX_Dashboard.Models
{
internal class SurpportLogLevel
{
internal LogEventLevel LogEventLevel { get; set; }

internal string? LogLevelName { get; set; }

internal string? LogLevelDisplayName { get; set; }
}
}
3 changes: 2 additions & 1 deletion KitX Dashboard/Services/PluginsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ internal static void Execute(string msg, IPEndPoint endPoint)
{
try
{
var pluginStruct = (PluginStruct)JsonSerializer.Deserialize(msg, typeof(PluginStruct));
var pluginStruct = (PluginStruct)JsonSerializer.Deserialize(msg,
typeof(PluginStruct));

// 标注实例注册 ID
pluginStruct.Tags.Add("Authorized_ID",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal class PluginCardViewModel
public PluginCardViewModel()
{
pluginStruct.IconInBase64 = FileHelper.ReadAll(Path.GetFullPath($"./Assets/KitX.Base64.txt"));
Log.Information($"Icon Loaded: {pluginStruct.IconInBase64}");
}

internal string DisplayName => pluginStruct.DisplayName
Expand Down
Loading

0 comments on commit c2ff106

Please sign in to comment.