Migrating from Groovy to Scala here. So far I really like Scala, however I am instantly missing my @Slf4j annotation, where I could just have:
@Slf4j
class Fizz {
    void doSomething() {
      log.info("We're doing something now...")
    }
}
...and Groovy would create an SLF4J logger and inject it into Fizz's bytecode for me. It spared me from having to do the following in every single class:
class Fizz {
    Logger log = LoggerFactory.getLogger(Fizz)
    void doSomething() {
      log.info("We're doing something now...")
    }
}
I really miss this so far.
I'm wondering if I can use traits/mixins to do the same, but it would have to be generic so I could use it with any class:
trait MyLogger[T] {
    def log = Logger.getLogger(T)
}
Then:
class Fizz extends MyLogger[Fizz] {
  def doSomething() : Unit = {
    log.info("Doing something now...")
  }
}
etc. Is this possible to do? If so, am I close or way off base here?
 
    