LSSLogger 2.0.0

LSSLogger 2.0.0

Yuki Okudera 维护。



LSSLogger 2.0.0

  • YukiOkudera

LSSLogger

一个轻量级且简单的 Swifty 日志记录器。

Version Carthage Compatible License Platform

要求

Swift 版本 4.1 或更高

安装

CocoaPods

要使用 CocoaPods 将 LSSLogger 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

platform :ios, '9.0'
use_frameworks!

target '<TargetName>' do
    pod "LSSLogger"
end

然后,运行以下命令

$ pod install

Carthage

要使用 Carthage 将 LSSLogger 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它

github "stv-yokudera/LSSLogger" ~> 1.0

运行 carthage update 构建框架,并将构建好的 LSSLogger.framework 拖入您的 Xcode 项目。

设置

默认情况下,是否输出日志如下

日志级别 调试 信息 警告 错误 致命
输出到控制台
输出到日志文件 ×

在发布构建中不想要输出日志时,在AppDelegate中设置如下

func application(_ application: UIApplication,
                 didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    #if RELEASE
    // For release builds, logs aren't output to the console.
    LSSLogger.outputToConsoleEnabled(isEnabled: false)

    // For release builds, logs aren't output to the files.
    LSSLogger.outputToFileEnabled(isEnabled: false)
    #endif

    return true
}

并且,激活编译条件如下: 2018-05-15 0 23 38

使用

import LSSLogger

func debugLogDemo() {
    // Output to the console.
    LSSLogger.console.debug()
    LSSLogger.console.debug(message: "foo")
    LSSLogger.console.info()

    // Output to the file.
    LSSLogger.file.info(message: "bar")
    LSSLogger.file.warning()
    LSSLogger.file.error()
    LSSLogger.file.fatal()

    // Output to the console and file.
    LSSLogger.consoleAndFile.info(message: "foobar")
    LSSLogger.consoleAndFile.warning()
    LSSLogger.consoleAndFile.error()
    LSSLogger.consoleAndFile.fatal()
}

关于这个库,我在Qiita上也写了一篇文章。(Qiita的文章都是用日语写的。) https://qiita.com/okuderap/items/75f11230746eea59c695

作者

YukiOkudera, [email protected]

授权

LSSLogger根据MIT授权协议提供。更多信息请参阅LICENSE文件。