Skip to content

Instantly share code, notes, and snippets.

@iShawnWang
Last active August 22, 2017 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iShawnWang/2f58862e5bfcc1d9bc1498939b368067 to your computer and use it in GitHub Desktop.
Save iShawnWang/2f58862e5bfcc1d9bc1498939b368067 to your computer and use it in GitHub Desktop.
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