本页为译文。技术支持和视频教程主要使用英语,内容以英文页面为准。 英文版
日志
ToolboxLogger.Instance 按级别和类别过滤消息。默认的全局级别是 Warning,对 LogSettings 和新建的 ToolboxLogConfig 资源都是如此。
LogCategory |
内容 |
|---|---|
General |
不属于其他类别的消息。示例使用它。 |
DragDrop |
拖放、合并、脱离。指针移动期间有大量消息。 |
Window |
窗口注册、状态、外壳和模板。 |
Animation |
保留。运行时目前不在此类别中记录日志。 |
Layout |
布局计算和几何。 |
Input |
输入处理和手势识别。 |
Lifecycle |
外壳生命周期:状态转换、初始化、清理。 |
LogLevel 的值,输出由少到多:Disabled、Error、Warning、Info、Debug、Trace。
在代码中配置日志:
using UIToolbox.Logging;
public static class LogSetup
{
public static void Apply()
{
var settings = LogSettings.CreateDefault();
settings.SetCategoryLevel(LogCategory.DragDrop, LogLevel.Debug);
ToolboxLogger.Initialize(settings);
}
}
或者用菜单 Assets > Create > UI Toolbox > Log Configuration 创建一个资源,并把它传给 ToolboxLogger.Initialize(ToolboxLogConfig)。
LogSettings.CreateDebug() 和 LogSettings.CreateTrace() 是预设。UIToolbox.Utils.LoggingHelper 提供快捷方法:ConfigureQuietMode、ConfigureDebugMode、EnableCategoryDebugging、ConfigureMergeDebugging。