AELog 0.6.3

AELog 0.6.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布时间上次发布2022年3月
SPM支持SPM

tadija维护。



AELog 0.6.3

Language Swift 5.5 Platforms iOS | watchOS | tvOS | macOS CocoaPods Carthage Swift Package Manager License MIT

AELog

使用Swift编写的简单、轻量级和灵活的调试日志小工具

如果您发现自己处于以下情况,那么您可能希望使用AELog

  • 我只希望在项目工作期间将任何内容记录到控制台,然后在上线时将其关闭。
  • 我想要在文件级别上启用/禁用日志记录,并按照我喜欢的格式设置日志行。
  • 我只想得到这些,我只想尽快启动并运行。

索引

功能

  • 顶层日志记录,在需要时可以禁用
  • 启用或禁用文件级别的日志记录
  • 可自定义的日志行格式和详细程度

用法

/// Log detailed debugging information with a simple one liner:

aelog()

/// - Note: if this was on line 21 in `viewDidLoad` of a `ViewController`, output could look like this:
/// 2016-04-03 21:08:00.123 -- [Main] ViewController (21) -> viewDidLoad() >

/// Add custom text to log line:

aelog("hi there")

/// Log random items (some interesting variables at the moment)

let text = "One two three four five"
let x: CGFloat = 21
let y: CGFloat = 8
let size = CGSize(width: 19, height: 84)
let rect = CGRect(x: x, y: y, width: size.width, height: size.height)
let range = 1...5

aelog(text, x, y, size, rect, range, Log.shared, self)

/// - Note: in this case output could look like this:
/// 04:01:05.967 -- ViewController (30) -> viewDidAppear > 

/// #0: String | "One two three four five"
/// #1: Double | 21.0
/// #2: Double | 8.0
/// #3: CGSize | (19.0, 84.0)
/// #4: CGRect | (21.0, 8.0, 19.0, 84.0)
/// #5: CountableClosedRange<Int> | CountableClosedRange(1...5)
/// #6: Log | AELog.Log
/// #7: ViewController | <AELogDemo_iOS.ViewController: 0x7fd14c41dd60>

/// Log both to debugger and device console:

aelog("this should be logged just in case...", mode: .nsLog)

/// Log Settings

/// Enable or disable logging with one flag and customize formatting as you like.
/// - Warning: `aelog` will by default work only if logging is enabled and file is not disabled in settings,
/// otherwise it will do nothing, but with `mode: .nsLog` it will always work, wether logging is enabled or not.

let settings = Log.shared.settings

settings.isEnabled = true
settings.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
settings.template = "{date} -- [{thread}] {file} ({line}) -> {function} > {text}"

/// - Note: toggle logging for specific files like this:
settings.files = [
    "AppDelegate" : false,
    "ViewController" : true
]

/// LogDelegate

Log.shared.delegate = self

func didLog(line: Line, mode: Log.Mode) {
    /// - Note: do something here?
}

再谈一事

当你不在电脑前时,有没有想过实时查看你App的输出,就像直接在你的iOS设备上一样?是的,我也没有,但是以防你改变主意(就像我一样),请查看AEConsole - 可定制的控制台UI叠加,在iOS应用的顶部呈现调试日志。毕竟,AELog就是为了补充AEConsole而开发的。

安装

许可

AELog遵循MIT许可。有关详细信息,请参阅LICENSE