Может быть, что-то подобное?
trait LoggableString {this: ActorLogging =>
private val logger = log //since there's name collision, we need to capture log method
implicit class RichString(s: String) {
def log() = logger.info(s)
}
}
class MyActor extends Actor with ActorLogging with LoggableString {
override def receive: Receive = {
case msg => "Hello".log
}
}
Или другое решение, предложенное Алексеем Романовым:
trait ExtendedActorLogging extends ActorLogging {this: Actor =>
private val logger = log
implicit class RichString(s: String) {
def log() = logger.info(s)
}
}
class MyActor extends Actor with ExtendedActorLogging {
override def receive: Receive = {
case msg => "Hello".log
}
}