https://kotlinlang.org logo
#announcements
Title
# announcements
g

groostav

08/08/2016, 9:48 PM
So, I'm also wondering how much syntactic sugar you guys put on logging. I'm thinking about doing something like
Copy code
val Any.log : Logger get() = Logger.getLogger(this.javaclass.canonicalName)
operator fun Logger.get(level: Level) = //... would have to return some intermediate type 'LeveledLogger'
operator fun LeveledLogger.plusAssign(entryContent: () -> Pair<String, Exception>) = //...
which gives me the syntax
Copy code
fun someMethod(){
  try {
    somethingComplicated();
  }
  catch(ex: ItWentBadException){
    log[WARNING] += { "Its gonna blow!" to ex }
  }
}