SwiftyBeaver 是 Swift 的一个多彩的、可扩展的、轻量级的日志记录器。
Xcode 控制台输出日志
日志写入文件
示例代码:
import SwiftyBeaver let log = SwiftyBeaver.self // add log destinations. at least one is needed! let console = ConsoleDestination() // log to Xcode Console let file = FileDestination() // log to default swiftybeaver.log file let cloud = SBPlatformDestination(appID: "foo", appSecret: "bar", encryptionKey: "123") // to cloud log.addDestination(console) log.addDestination(file) log.addDestination(cloud) // Now let’s log! log.verbose("not so important") // prio 1, VERBOSE in silver log.debug("something to debug") // prio 2, DEBUG in green log.info("a nice information") // prio 3, INFO in blue log.warning("oh no, that won’t be good") // prio 4, WARNING in yellow log.error("ouch, an error did occur!") // prio 5, ERROR in red // log anything! log.verbose(123) log.info(-123.45678) log.warning(NSDate()) log.error(["I", "like", "logs!"]) log.error(["name": "Mr Beaver", "address": "7 Beaver Lodge"])