Add option to get trace as a string in toArray()