LSSLogger
A Lightweight and simple Swifty Logger.
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:
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.