I'm new to Scala with Akka. I'm using LoggingAdapter to log ByteString messages. I see a common scenario where a decently large message gets truncated. For example,
I need to see the entire message. Please help me here.
CodePudding user response:
This is because of the logic in akka.util.ByteString.toString method:
override def toString(): String = {
val maxSize = 100
if (size > maxSize)
take(maxSize).toString s"... and [${size - maxSize}] more"
else
super.toString
}
you can convert ByteString to List and this will print everything.
val myBs: ByteString = ??? //some very long ByteString
println(myBs) //this will get truncated
println(myBs.toList) //but this will not
CodePudding user response:
We can convert the ByteString to an array and then print the individual bytes in a space-separated manner.
val myArr : Array[Byte] = byteStringMessage.toArray
log.info(s" byte array : ${myArr.mkString(" ")}")

