diff --git a/.gitignore b/.gitignore index e9fe3cf..ab237d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,20 @@ -.vs/ProjectEvaluation/xploreplane.metadata.v10.bin -.vs/ProjectEvaluation/xploreplane.projects.v10.bin -.vs/ProjectEvaluation/xploreplane.strings.v10.bin -.vs/XplorePlane/DesignTimeBuild/.dtbcache.v2 -.vs/XplorePlane/FileContentIndex/241be4f9-f3c1-44c3-a625-51f3a7efa276.vsidx -.vs/XplorePlane/FileContentIndex/a28e3b89-b000-44c7-aab5-785c933af59b.vsidx -.vs/XplorePlane/FileContentIndex/a475b41e-8352-4745-8040-08886d83ddf4.vsidx -.vs/XplorePlane/FileContentIndex/bdb864e9-e54b-49df-bf87-9b121265e567.vsidx -.vs/XplorePlane/v18/.futdcache.v2 -.vs/XplorePlane/v18/.suo -.vs/XplorePlane/v18/DocumentLayout.backup.json -.vs/XplorePlane/v18/DocumentLayout.json +# .gitignore 文件内容 +# 忽略编译输出 +**/bin/ +**/obj/ +**/Debug/ +**/Release/ + +# 忽略用户配置文件 +.vs/ +.vscode/ +*.user +*.suo + +# 忽略Nuget包 +packages/ +*.nupkg +**/.vs XplorePlane/obj/project.assets.json XplorePlane/obj/* diff --git a/README.md b/README.md index d9b18ad..ebecf6c 100644 --- a/README.md +++ b/README.md @@ -62,70 +62,6 @@ XplorePlane/ - - - - - -### 日志系统 - -项目通过引用 **XplorePlane.Common.dll** 库使用统一的日志功能,无需在本项目中重复实现。 - -- **日志框架**: Serilog 4.3.1(来自 XplorePlane.Common.dll) -- **日志输出**: 控制台、文件(按天滚动)、调试输出 -- **日志路径**: `logs/xploreplane-YYYYMMDD.log` -- **配置文件**: `App.config` -- **服务接口**: `XplorePlane.Common.Logging.Interfaces.ILoggerService` - -**使用方式 1 - 使用 Serilog ILogger(推荐)**: - -```csharp -using Serilog; - -public class MyViewModel -{ - private readonly ILogger _logger; - - public MyViewModel(ILogger logger) - { - _logger = logger.ForContext(); - } - - public void DoSomething() - { - _logger.Information("执行操作"); - _logger.Debug("调试信息:参数={Value}", someValue); - } -} -``` - -**使用方式 2 - 使用 XplorePlane.Common.ILoggerService**: - -```csharp -using XplorePlane.Common.Logging.Interfaces; - -public class MyService -{ - private readonly ILoggerService _logger; - - public MyService(ILoggerService logger) - { - _logger = logger.ForModule(); - } - - public void DoWork() - { - _logger.Info("开始工作"); - _logger.Debug("调试信息:参数={Value}", someValue); - } -} -``` - -详细使用指南请参考: -- [快速开始指南](QUICK_START.md) -- [日志集成说明](Doc/LOGGING_INTEGRATION.md) -- [日志使用示例](Services/LoggingUsageExample.cs) - ### TO-DO List - [x] 软件基于 WPF + Prism 基础的框架 @@ -136,10 +72,4 @@ public class MyService - [ ] 打通与硬件层的调用流程 - [ ] 打通与图像层的调用流程 -### 文档 -- [快速开始指南](QUICK_START.md) - 快速上手指南 -- [DLL 集成方案](Doc/DLL_INTEGRATION.md) - 硬件库 DLL 集成方案 -- [日志集成说明](Doc/LOGGING_INTEGRATION.md) - 日志系统集成说明 -- [项目架构](Doc/PROJECT_ARCHITECTURE.md) - 项目整体架构 -- [硬件集成技术方案](Doc/HARDWARE_INTEGRATION_TECHNICAL_SCHEME.md) - 硬件集成技术方案 diff --git a/XplorePlane/App.xaml.cs b/XplorePlane/App.xaml.cs index 685fe2f..180f1b3 100644 --- a/XplorePlane/App.xaml.cs +++ b/XplorePlane/App.xaml.cs @@ -5,7 +5,6 @@ using XplorePlane.ViewModels; using Prism.Ioc; using Prism.DryIoc; using Serilog; -using XplorePlane.Common.Logging; namespace XplorePlane { @@ -16,8 +15,8 @@ namespace XplorePlane { protected override void OnStartup(StartupEventArgs e) { - // 使用 XplorePlane.Common.dll 中的日志配置 - LoggerConfig.Initialize("XplorePlane"); + // 配置 Serilog 日志系统 + ConfigureLogging(); // 捕获未处理的异常 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; @@ -30,10 +29,27 @@ namespace XplorePlane bootstrapper.Run(); } + private void ConfigureLogging() + { + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Debug() + .WriteTo.Console() + .WriteTo.File("logs/xploreplane-.log", + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: 30) + .CreateLogger(); + + Log.Information("========================================"); + Log.Information("XplorePlane 应用程序启动"); + Log.Information("========================================"); + } + protected override void OnExit(ExitEventArgs e) { // 关闭并刷新日志 + Log.Information("========================================"); Log.Information("XplorePlane 应用程序退出"); + Log.Information("========================================"); Log.CloseAndFlush(); base.OnExit(e); } diff --git a/XplorePlane/ViewModels/MainViewModel.cs b/XplorePlane/ViewModels/MainViewModel.cs index 2c3f165..a325af7 100644 --- a/XplorePlane/ViewModels/MainViewModel.cs +++ b/XplorePlane/ViewModels/MainViewModel.cs @@ -1,13 +1,13 @@ using Prism.Commands; using Prism.Mvvm; using System.Collections.ObjectModel; -using XplorePlane.Services; +using Serilog; namespace XplorePlane.ViewModels { public class MainViewModel : BindableBase { - private readonly ILoggerService _logger; + private readonly ILogger _logger; private string _licenseInfo = "当前时间"; public string LicenseInfo @@ -25,9 +25,9 @@ namespace XplorePlane.ViewModels public DelegateCommand ClearCommand { get; set; } public DelegateCommand EditPropertiesCommand { get; set; } - public MainViewModel(ILoggerService logger) + public MainViewModel(ILogger logger) { - _logger = logger?.ForModule() ?? throw new System.ArgumentNullException(nameof(logger)); + _logger = logger?.ForContext() ?? throw new System.ArgumentNullException(nameof(logger)); NavigationTree = new ObservableCollection(); @@ -38,42 +38,42 @@ namespace XplorePlane.ViewModels ClearCommand = new DelegateCommand(OnClear); EditPropertiesCommand = new DelegateCommand(OnEditProperties); - _logger.Info("MainViewModel 已初始化"); + _logger.Information("MainViewModel 已初始化"); } private void OnNavigateHome() { - _logger.Info("导航到主页"); + _logger.Information("导航到主页"); LicenseInfo = "主页"; } private void OnNavigateInspect() { - _logger.Info("导航到检测页面"); + _logger.Information("导航到检测页面"); LicenseInfo = "检测页面"; } private void OnOpenFile() { - _logger.Info("打开文件"); + _logger.Information("打开文件"); LicenseInfo = "打开文件"; } private void OnExport() { - _logger.Info("导出数据"); + _logger.Information("导出数据"); LicenseInfo = "导出数据"; } private void OnClear() { - _logger.Info("清除数据"); + _logger.Information("清除数据"); LicenseInfo = "清除数据"; } private void OnEditProperties() { - _logger.Info("编辑属性"); + _logger.Information("编辑属性"); LicenseInfo = "编辑属性"; } } diff --git a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.deps.json b/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.deps.json deleted file mode 100644 index 157eff2..0000000 --- a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.deps.json +++ /dev/null @@ -1,329 +0,0 @@ -{ - "runtimeTarget": { - "name": ".NETCoreApp,Version=v8.0", - "signature": "" - }, - "compilationOptions": {}, - "targets": { - ".NETCoreApp,Version=v8.0": { - "XplorePlane/1.0.0": { - "dependencies": { - "Fluent.Ribbon": "9.0.0", - "Prism.DryIoc": "9.0.537", - "Serilog": "4.3.1", - "Serilog.Sinks.Console": "6.1.1", - "Serilog.Sinks.Debug": "3.0.0", - "Serilog.Sinks.File": "7.0.0", - "System.Configuration.ConfigurationManager": "8.0.0" - }, - "runtime": { - "XplorePlane.dll": {} - } - }, - "ControlzEx/5.0.1": { - "dependencies": { - "Microsoft.Xaml.Behaviors.Wpf": "1.1.122", - "System.Text.Json": "5.0.1" - }, - "runtime": { - "lib/net5.0-windows7.0/ControlzEx.dll": { - "assemblyVersion": "5.0.0.0", - "fileVersion": "5.0.1.15" - } - } - }, - "DryIoc.dll/5.4.3": { - "runtime": { - "lib/net7.0/DryIoc.dll": { - "assemblyVersion": "5.4.3.0", - "fileVersion": "5.4.3.0" - } - } - }, - "Fluent.Ribbon/9.0.0": { - "dependencies": { - "ControlzEx": "5.0.1" - }, - "runtime": { - "lib/net5.0-windows7.0/Fluent.dll": { - "assemblyVersion": "9.0.0.0", - "fileVersion": "9.0.0.0" - } - } - }, - "Microsoft.Extensions.DependencyInjection.Abstractions/8.0.1": { - "runtime": { - "lib/net8.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": { - "assemblyVersion": "8.0.0.0", - "fileVersion": "8.0.324.11423" - } - } - }, - "Microsoft.Xaml.Behaviors.Wpf/1.1.122": { - "runtime": { - "lib/net6.0-windows7.0/Microsoft.Xaml.Behaviors.dll": { - "assemblyVersion": "1.1.0.0", - "fileVersion": "1.1.122.28819" - } - } - }, - "Prism.Container.Abstractions/9.0.106": { - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.1" - }, - "runtime": { - "lib/net8.0/Prism.Container.Abstractions.dll": { - "assemblyVersion": "9.0.106.9543", - "fileVersion": "9.0.106.9543" - } - } - }, - "Prism.Container.DryIoc/9.0.106": { - "dependencies": { - "DryIoc.dll": "5.4.3", - "Prism.Container.Abstractions": "9.0.106" - }, - "runtime": { - "lib/net8.0/Prism.Container.DryIoc.dll": { - "assemblyVersion": "9.0.106.9543", - "fileVersion": "9.0.106.9543" - } - } - }, - "Prism.Core/9.0.537": { - "dependencies": { - "Prism.Container.Abstractions": "9.0.106", - "Prism.Events": "9.0.537" - }, - "runtime": { - "lib/net6.0/Prism.dll": { - "assemblyVersion": "9.0.537.60525", - "fileVersion": "9.0.537.60525" - } - } - }, - "Prism.DryIoc/9.0.537": { - "dependencies": { - "Prism.Container.DryIoc": "9.0.106", - "Prism.Wpf": "9.0.537" - }, - "runtime": { - "lib/net6.0-windows7.0/Prism.DryIoc.Wpf.dll": { - "assemblyVersion": "9.0.537.60525", - "fileVersion": "9.0.537.60525" - } - } - }, - "Prism.Events/9.0.537": { - "runtime": { - "lib/net6.0/Prism.Events.dll": { - "assemblyVersion": "9.0.537.60525", - "fileVersion": "9.0.537.60525" - } - } - }, - "Prism.Wpf/9.0.537": { - "dependencies": { - "Microsoft.Xaml.Behaviors.Wpf": "1.1.122", - "Prism.Core": "9.0.537" - }, - "runtime": { - "lib/net6.0-windows7.0/Prism.Wpf.dll": { - "assemblyVersion": "9.0.537.60525", - "fileVersion": "9.0.537.60525" - } - } - }, - "Serilog/4.3.1": { - "runtime": { - "lib/net8.0/Serilog.dll": { - "assemblyVersion": "4.3.0.0", - "fileVersion": "4.3.0.0" - } - } - }, - "Serilog.Sinks.Console/6.1.1": { - "dependencies": { - "Serilog": "4.3.1" - }, - "runtime": { - "lib/net8.0/Serilog.Sinks.Console.dll": { - "assemblyVersion": "6.1.1.0", - "fileVersion": "6.1.1.0" - } - } - }, - "Serilog.Sinks.Debug/3.0.0": { - "dependencies": { - "Serilog": "4.3.1" - }, - "runtime": { - "lib/net8.0/Serilog.Sinks.Debug.dll": { - "assemblyVersion": "3.0.0.0", - "fileVersion": "3.0.0.0" - } - } - }, - "Serilog.Sinks.File/7.0.0": { - "dependencies": { - "Serilog": "4.3.1" - }, - "runtime": { - "lib/net8.0/Serilog.Sinks.File.dll": { - "assemblyVersion": "7.0.0.0", - "fileVersion": "7.0.0.0" - } - } - }, - "System.Configuration.ConfigurationManager/8.0.0": { - "dependencies": { - "System.Diagnostics.EventLog": "8.0.0", - "System.Security.Cryptography.ProtectedData": "8.0.0" - } - }, - "System.Diagnostics.EventLog/8.0.0": {}, - "System.Security.Cryptography.ProtectedData/8.0.0": {}, - "System.Text.Json/5.0.1": {} - } - }, - "libraries": { - "XplorePlane/1.0.0": { - "type": "project", - "serviceable": false, - "sha512": "" - }, - "ControlzEx/5.0.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-DVJJmmnKXcVh3Bs2gKpAdPCT8HrkYTagSbFg0P9xHjp8dox9bKeaoVj9VGhPRzP9+LHs5MUXxN07/oGqeXNNcg==", - "path": "controlzex/5.0.1", - "hashPath": "controlzex.5.0.1.nupkg.sha512" - }, - "DryIoc.dll/5.4.3": { - "type": "package", - "serviceable": true, - "sha512": "sha512-yhXOG3SOxeWYxBAWskNRDD8fzw5hriEawv4VN4WKaFHOuubiop4kxe2rkWTEyCnTgRVgxVUSQCDBBkZqwPm1iQ==", - "path": "dryioc.dll/5.4.3", - "hashPath": "dryioc.dll.5.4.3.nupkg.sha512" - }, - "Fluent.Ribbon/9.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-29N3G7EM1WFgNofj4wEaufFaB8Iakjn/CZskq3kHKR93myxJ2iV0k6xLH3rhg9l/QATboPExV0WONT/ZfQcOVg==", - "path": "fluent.ribbon/9.0.0", - "hashPath": "fluent.ribbon.9.0.0.nupkg.sha512" - }, - "Microsoft.Extensions.DependencyInjection.Abstractions/8.0.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-fGLiCRLMYd00JYpClraLjJTNKLmMJPnqxMaiRzEBIIvevlzxz33mXy39Lkd48hu1G+N21S7QpaO5ZzKsI6FRuA==", - "path": "microsoft.extensions.dependencyinjection.abstractions/8.0.1", - "hashPath": "microsoft.extensions.dependencyinjection.abstractions.8.0.1.nupkg.sha512" - }, - "Microsoft.Xaml.Behaviors.Wpf/1.1.122": { - "type": "package", - "serviceable": true, - "sha512": "sha512-SgcafT189u4qX++vSCV9FLQ4BsRXU9J2esnHA9IF8GOSgnPBulFw1CW4X/FYoOXvZwdDZxlSObJUGUg1U1wSyg==", - "path": "microsoft.xaml.behaviors.wpf/1.1.122", - "hashPath": "microsoft.xaml.behaviors.wpf.1.1.122.nupkg.sha512" - }, - "Prism.Container.Abstractions/9.0.106": { - "type": "package", - "serviceable": true, - "sha512": "sha512-QNOERNOqsxvAa8pbWjqFB872DkvYK/cVRrcFO5vJYgWTIKBd8xfaI/jaZ0qeXLYVDz0nrvgJTZVVnip6+68dCw==", - "path": "prism.container.abstractions/9.0.106", - "hashPath": "prism.container.abstractions.9.0.106.nupkg.sha512" - }, - "Prism.Container.DryIoc/9.0.106": { - "type": "package", - "serviceable": true, - "sha512": "sha512-g7UzyK4oRPmEGgz2CV976KTBFk+QPdfktyrL91kvI4YbHciQATO6/r1KFnyRnBE73il5v+SeXXKWIrvlMnsMdg==", - "path": "prism.container.dryioc/9.0.106", - "hashPath": "prism.container.dryioc.9.0.106.nupkg.sha512" - }, - "Prism.Core/9.0.537": { - "type": "package", - "serviceable": true, - "sha512": "sha512-D7mEqPKLVNrD0g2WHCpC/MOKwn8h7X1liCWyjqjL7NCuxgwuhVLTG85E/ZPBkISrXdwvOQZ+bSY31bvP79FQlg==", - "path": "prism.core/9.0.537", - "hashPath": "prism.core.9.0.537.nupkg.sha512" - }, - "Prism.DryIoc/9.0.537": { - "type": "package", - "serviceable": true, - "sha512": "sha512-tnKifVxlKeSbNP2gZi+nMcjsi/w0lm3aLhBh92gWO6uCoa44ACM9gVJeO77ew4aHYZuoHUd6wHyeozfN7QKWuA==", - "path": "prism.dryioc/9.0.537", - "hashPath": "prism.dryioc.9.0.537.nupkg.sha512" - }, - "Prism.Events/9.0.537": { - "type": "package", - "serviceable": true, - "sha512": "sha512-Pzp5MGUuhAyKXZUbHVYNWLGF/eA3sScqDN6VrzbWlKj85R0IS0q+JXe99umynso2xhXAe+1jrQCCkgqmEFCBng==", - "path": "prism.events/9.0.537", - "hashPath": "prism.events.9.0.537.nupkg.sha512" - }, - "Prism.Wpf/9.0.537": { - "type": "package", - "serviceable": true, - "sha512": "sha512-srsXhi7FRUFawsNoRkY67duMEGjZo3ff0FpqpkjeWkkAuLazlH1UmNVrvwnpaLQCBboexH/z6oGrLvpeocxgdw==", - "path": "prism.wpf/9.0.537", - "hashPath": "prism.wpf.9.0.537.nupkg.sha512" - }, - "Serilog/4.3.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-savYe7h5yRlkqBVOwP8cIRDOdqKiPmYCU4W87JH38sBmcKD5EBoXvQIw6bNEvZ/pTe1gsiye3VFCzBsoppGkXQ==", - "path": "serilog/4.3.1", - "hashPath": "serilog.4.3.1.nupkg.sha512" - }, - "Serilog.Sinks.Console/6.1.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-8jbqgjUyZlfCuSTaJk6lOca465OndqOz3KZP6Cryt/IqZYybyBu7GP0fE/AXBzrrQB3EBmQntBFAvMVz1COvAA==", - "path": "serilog.sinks.console/6.1.1", - "hashPath": "serilog.sinks.console.6.1.1.nupkg.sha512" - }, - "Serilog.Sinks.Debug/3.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-4BzXcdrgRX7wde9PmHuYd9U6YqycCC28hhpKonK7hx0wb19eiuRj16fPcPSVp0o/Y1ipJuNLYQ00R3q2Zs8FDA==", - "path": "serilog.sinks.debug/3.0.0", - "hashPath": "serilog.sinks.debug.3.0.0.nupkg.sha512" - }, - "Serilog.Sinks.File/7.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-fKL7mXv7qaiNBUC71ssvn/dU0k9t0o45+qm2XgKAlSt19xF+ijjxyA3R6HmCgfKEKwfcfkwWjayuQtRueZFkYw==", - "path": "serilog.sinks.file/7.0.0", - "hashPath": "serilog.sinks.file.7.0.0.nupkg.sha512" - }, - "System.Configuration.ConfigurationManager/8.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-JlYi9XVvIREURRUlGMr1F6vOFLk7YSY4p1vHo4kX3tQ0AGrjqlRWHDi66ImHhy6qwXBG3BJ6Y1QlYQ+Qz6Xgww==", - "path": "system.configuration.configurationmanager/8.0.0", - "hashPath": "system.configuration.configurationmanager.8.0.0.nupkg.sha512" - }, - "System.Diagnostics.EventLog/8.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-fdYxcRjQqTTacKId/2IECojlDSFvp7LP5N78+0z/xH7v/Tuw5ZAxu23Y6PTCRinqyu2ePx+Gn1098NC6jM6d+A==", - "path": "system.diagnostics.eventlog/8.0.0", - "hashPath": "system.diagnostics.eventlog.8.0.0.nupkg.sha512" - }, - "System.Security.Cryptography.ProtectedData/8.0.0": { - "type": "package", - "serviceable": true, - "sha512": "sha512-+TUFINV2q2ifyXauQXRwy4CiBhqvDEDZeVJU7qfxya4aRYOKzVBpN+4acx25VcPB9ywUN6C0n8drWl110PhZEg==", - "path": "system.security.cryptography.protecteddata/8.0.0", - "hashPath": "system.security.cryptography.protecteddata.8.0.0.nupkg.sha512" - }, - "System.Text.Json/5.0.1": { - "type": "package", - "serviceable": true, - "sha512": "sha512-/UM3UK1dXKl8Ybysg/21gM4S8DJgkR+yLU8JwqCVbuNqQNImelntgYFAN5QxR8sJJ1kMx//hOUdf0lltosi8cQ==", - "path": "system.text.json/5.0.1", - "hashPath": "system.text.json.5.0.1.nupkg.sha512" - } - } -} \ No newline at end of file diff --git a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.dll b/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.dll deleted file mode 100644 index 86e4f21..0000000 Binary files a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.dll and /dev/null differ diff --git a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.exe b/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.exe deleted file mode 100644 index d557090..0000000 Binary files a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.exe and /dev/null differ diff --git a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.pdb b/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.pdb deleted file mode 100644 index d42c646..0000000 Binary files a/XplorePlane/bin/Debug/net8.0-windows/XplorePlane.pdb and /dev/null differ