A Lightweight and simple Swifty Logger.
Swift Version 5.0 or more
To integrate LSSLogger into your Xcode project using CocoaPods, specify it in your Podfile
:
platform :ios, '11.0'
use_frameworks!
target '<TargetName>' do
pod "LSSLogger"
end
Then, run the following command:
$ pod install
To integrate LSSLogger into your Xcode project using Carthage, specify it in your Cartfile
:
github "y-okudera/LSSLogger" ~> 2.0
Run carthage update
to build the framework and drag the built LSSLogger.framework
into your Xcode project.
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: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Set the log rotation count. (default: 10files)
LSSLogger.configureLogRotationCount(count: 5)
#if RELEASE
// For release builds, logs are not output to the console.
LSSLogger.outputToConsoleEnabled(isEnabled: false)
// For release builds, logs are not output to files.
LSSLogger.outputToFileEnabled(isEnabled: false)
#endif
return true
}
And, Active Compilation Conditions is as follows:
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, appledev.yuoku@gmail.com
LSSLogger is available under the MIT license. See the LICENSE file for more info.