LSSLogger 2.0.0

LSSLogger 2.0.0

Maintained by Yuki Okudera.



LSSLogger 2.0.0

  • By
  • YukiOkudera

LSSLogger

A Lightweight and simple Swifty Logger.

Version Carthage Compatible License Platform

Requirements

Swift Version 4.1 or more

Installation

CocoaPods

To integrate LSSLogger into your Xcode project using CocoaPods, specify it in your Podfile:

platform :ios, '9.0'
use_frameworks!

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

Then, run the following command:

$ pod install

Carthage

To integrate LSSLogger into your Xcode project using Carthage, specify it in your Cartfile:

github "stv-yokudera/LSSLogger" ~> 1.0

Run carthage update to build the framework and drag the built LSSLogger.framework into your Xcode project.

Setup

By default, whether to output logs is as follows:

LogLevel DEBUG INFO WARNING ERROR FATAL
Output to console
Output to log file ×

When you don't want to output the log in the release build, In AppDelegate, set as follows:

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
}

And, Active Compilation Conditions is as follows: 2018-05-15 0 23 38

Usage

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

Author

YukiOkudera, [email protected]

License

LSSLogger is available under the MIT license. See the LICENSE file for more info.