Projects

CodeWF.LogViewer

Lightweight log library and Avalonia log viewing control

项目说明

CodeWF.LogViewer

CodeWF.LogViewer

CodeWF.LogViewer 包含轻量级日志核心库和 Avalonia UI 日志展示控件。核心包可用于控制台、WPF、WinForms、Avalonia 等 C# 程序;Avalonia 控件则负责把日志实时显示在界面上,适合桌面应用调试和工具型客户端。

envelope

package description applicable scenarios
CodeWF.Log.Core The core log library relies only on. NET. Console, WPF, WinForms, Avalonia and other C#programs.
CodeWF.LogViewer.Avalonia Avalonia UI log display control. The Avalonia UI program has an embedded log window.

installation

Install-Package CodeWF.Log.Core
Install-Package CodeWF.LogViewer.Avalonia

basic use

Logger.Debug("调试日志");
Logger.Info("普通日志");
Logger.Warn("警告日志");
Logger.Error("错误日志");
Logger.Fatal("严重错误日志");

When console programs use file logs, it is recommended to handle file channels at startup and exit:

Logger.RecordToFile();

// 程序退出时刷新缓冲区
await Logger.FlushAsync();

output target control

Each logging method controls whether output to the UI, files, and console:

Logger.Info(
    content: "写入文件的内容",
    uiContent: "UI 显示的友好内容",
    log2UI: true,
    log2File: true,
    log2Console: true);

You can also use shortcuts:

Logger.InfoToFile("仅写入文件");
Logger.LogToUI(LogType.Info, "仅显示 UI");

Avalonia controls

Introducing namespaces and placing controls in AXAML:

xmlns:log="https://codewf.com"
<log:LogView />

LogView 内部会启动文件日志记录,并从 UI 通道消费日志显示到界面。高频日志场景中,控件使用批量处理和防抖刷新,避免界面频繁重绘。

warehouse