Files
LanMountainDesktop/LanMountainDesktop.Platform.Abstractions/PlatformLog.cs
lincube 9b7a35ddd3 refactor: 新建 Platform 平台差异层,主工程 P/Invoke 全部迁出
- 新增 Platform.Abstractions(接口+NoOp+PlatformLog 日志桥)、
  Platform.Windows、Platform.MacOS、Platform.Android 四个项目
- 迁移电源管理、原生对话框、桌面层嵌入、窗口置底/区域穿透、
  DWM 互操作、图标服务、包标识查询等全部 Windows P/Invoke 实现
- 主工程保留静态工厂门面,调用点不变;DllImport 扫描为零
- 更新 WindowPassthroughServiceTests 指向新位置(20/20 通过)
2026-07-26 22:14:46 +09:00

36 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}