Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom CleanroomLogger Channel demo
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?
}
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
You can’t perform that action at this time.