Last active
August 22, 2017 17:07
-
-
Save iShawnWang/2f58862e5bfcc1d9bc1498939b368067 to your computer and use it in GitHub Desktop.
Custom CleanroomLogger Channel demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original issues : [CleanroomLogger/issues/37](https://github.com/emaloney/CleanroomLogger/issues/37) | |
extension Log { | |
static func setup() { | |
#if DEBUG | |
Log.enable(debugMode: true) | |
Log.sqlite = MyLogChannel(prefix: "Sqlite") // enable your channel or using Xcode console filter | |
#endif | |
} | |
} | |
extension Log { | |
// Adapter Class | |
class MyLogChannel{ | |
let prefix:String | |
init(prefix:String) { | |
self.prefix = prefix | |
} | |
func info(_ msg: String?, function: String = #function, filePath: String = #file, fileLine: Int = #line) { | |
guard let msg = msg else {return} | |
Log.info?.message(prefix + " : " + msg, function: function, filePath: filePath, fileLine: fileLine) | |
} | |
} | |
static var sqlite:MyLogChannel? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Log.sqlite.info("666") | |
or | |
declare a global const `LogSqlite` | |
let LogSqlite = Log.sqlite | |
LogSqlite.info("hehe") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment