NLog 3.0.4

NLog 3.0.4

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最新发布2016年11月
SwiftSwift 版本3.0
SPM支持 SPM

Nguyen Phu Nghia 维护。



 
依赖
RealmSwift>= 0
Realm>= 0
NLogProtocol>= 0
 

NLog 3.0.4

  • 作者
  • Nghia Nguyen

NLog 1.0.9

NLog 是一个快速、简单且功能更强大的 iOS 日志框架。

灵感来源于 CocoalumberjackLog 和 RGA Log。

变更日志

**v3.0.3 - 2016年10月31日 没有注释

**v3.0.2 - 2016年10月31日 更新语法为 Swift 3

**v1.2.26 - 2016年10月31日 更新 NLogProtocol

**v1.2.25 - 2016年10月31日 更新 NLogProtocol

**v1.2.24 - 2016年10月31日 添加 NLogProtocol

**v1.2.23 - 2016年10月19日 测试语言2

**v1.2.22 - 2016年10月19日

asdfasdf

v1.0.9 - 2016年3月20日

  1. 支持 XcodeColors 插件,使得控制台日志多彩。
  2. 添加堆栈跟踪选项。
  3. 添加 2 个静态属性 userEmail 和 userId 到 NKFeedbackMailViewController。

v1.0.5 - 2016年3月4日

  1. 在 NKDebugViewController 中添加功能:"发送带有日志加当前窗口截图的反馈"。

安装

Pod

use_frameworks!

pod 'NLog'

用法

import NLog

日志级别

public enum Level: String {
  case Info =  "Info"
  case Error = "Error"
  case Debug = "Debug"
  case Warning = "Warning"
  case Server = "Server"
}

打印日志

NLog.debug("Hello world!")
带有标签的日志打印
NLog.server("Authentication failed", "OWNER_SERVER") // Tag = OWNER_SERVER
带有特定颜色的日志打印 --- 用于在 NLogViewController 中显示日志
NLog.info("More colorful", color: UIColor.blueColor())

可选设置

NLog.rollingFrequency = 3600 * 24 * 7 // auto remove log overdue for a week.
NLog.limitDisplayedCharacters = 1000 // limit displayed chracteristics of a message on console log.
NLog.levels = [.Debug, .Error, .Server] // only allow this levels - Default is allow all.
NLog.filters = ["Apple", "Orange", "Banana"] // only allow logs contain filters.
NLog.maxStackTrace = 10 // maximum stack you wanna trace
NLog.replaceNLog = {(level, tag, message, color, file, function, line) in
    //maybe in some cases, you don't wanna use us, can use this to replace NLog by another Log you want.
}

NLog.levelColors[.Debug] = UIColor.blueColor() // change the default level color

查询日志

let logString = NLog.getLogString() // get all log

// get with filter
let logStringFiltered = NLog.getLogString(level: .Server, tag: "OWNER_SERVER", filter: "user/me", limit: 1000, stackTrace: false)

保存日志到文件

NLog.saveToFile(path: "../log.txt") // optional filter like query log

NLogViewController

NLog提供用于查看日志的视图,例如控制台日志和其他更多功能。

  1. 搜索消息。
  2. 过滤日志级别和标签。
  3. 查看日志详细信息。
  4. 用颜色区分日志级别。
  5. 发送反馈,附件包含日志加当前窗口的快照。

NLogViewController