mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-08-19 01:53:24 +08:00
- 新增 Platform.Abstractions(接口+NoOp+PlatformLog 日志桥)、 Platform.Windows、Platform.MacOS、Platform.Android 四个项目 - 迁移电源管理、原生对话框、桌面层嵌入、窗口置底/区域穿透、 DWM 互操作、图标服务、包标识查询等全部 Windows P/Invoke 实现 - 主工程保留静态工厂门面,调用点不变;DllImport 扫描为零 - 更新 WindowPassthroughServiceTests 指向新位置(20/20 通过)
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
namespace LanMountainDesktop.Platform.Abstractions;
|
||
|
||
/// <summary>
|
||
/// 平台层日志桥。平台实现项目不引用宿主,
|
||
/// 宿主在启动时通过 <see cref="SetSink"/> 接入自己的日志系统(AppLogger)。
|
||
/// 未接入时日志静默丢弃。
|
||
/// </summary>
|
||
public static class PlatformLog
|
||
{
|
||
private static IPlatformLogSink? _sink;
|
||
|
||
public static void SetSink(IPlatformLogSink sink)
|
||
{
|
||
ArgumentNullException.ThrowIfNull(sink);
|
||
_sink = sink;
|
||
}
|
||
|
||
public static void Info(string category, string message) => _sink?.Info(category, message);
|
||
|
||
public static void Warn(string category, string message, Exception? exception = null) =>
|
||
_sink?.Warn(category, message, exception);
|
||
|
||
public static void Error(string category, string message, Exception? exception = null) =>
|
||
_sink?.Error(category, message, exception);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 平台层日志输出目标。
|
||
/// </summary>
|
||
public interface IPlatformLogSink
|
||
{
|
||
void Info(string category, string message);
|
||
void Warn(string category, string message, Exception? exception = null);
|
||
void Error(string category, string message, Exception? exception = null);
|
||
}
|