SwiftSupported Platforms: iOS, macOS, tvOS, watchOSLicense: MITPayPalDocC

Clarity 是一个日志框架,它通过数字引用 JSON 中的日志数据,并使用语义格式将输出显示在控制台中。

源代码

//Clarity print statements in source code
print(1, functionName: #function)
print(2)
print(3, values: [ 1,2,3])

控制台输出

MYCLASS  🏓f   52    myFunction()
MYCLASS        52    N-2    ✅  - An event occurred that is described here
                                  Effect: 'this' will happen next
MYCLASS        52    N-3    📋  - Values for variable are:
                                  1
																	2
																	3																	

概述

Clarity 假设应用程序控制流中,开发者主要关注三个“节点”:函数调用点、条件语句的解析以及特定值(包括错误)的报告。 Clarity 打印语句旨在放置在客户端应用程序源代码中的这些节点点上。

与每个打印语句相关的所有消息数据都完全放置在相关的 JSON 文件中,并通过唯一的数字引用。 这使得可以向控制台打印无限量的信息,而对源代码的影响可以忽略不计。

控制台日志输出的可定制格式旨在强调控制流清晰叙述中感兴趣的节点。 输出包括与代码的功能和目的相关的符号,以便人们一眼就能阅读和理解。

可自定义的过滤器设置可以打印特定的隔离元素和引用的数据。

最小的 API 包含 Swift print(_:separator:terminator:) 函数的两个重载类似物 – 这些函数:[print(_:functionName:settings:)](https://realint.org/documentation/clarity/print(_:functionname:settings:) 和 [print(_:values:settings:)](https://realint.org/documentation/clarity/print(_:values:settings:) 通过索引引用相关的 JSON 数据。

Release 2 中新增了两个函数,用于处理 Combine 发布者:[print(_:valuesForPublisherType:settings:)](https://realint.org/documentation/clarity/print(_:valuesforpublishertype:settings:)print(_:to:) 的扩展重载。

文档

Clarity 在 DocC 目录中进行了完整的文档记录,其中包括文章公共 API 参考教程

非公共 API 使用 Jazzy 进行了 100% 的文档记录。

安装

Clarity 最好作为 Swift 包安装

paypal

许可证

Clarity 在 MIT 许可下发布。 有关详细信息,请参阅 LICENSE

版权所有 (c) 2021-2022 Lawrence Heyfron https://realint.org/