Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering console output containing multiline strings in Xcode

I'm printing JSON data that spans multiple lines to the console. I'm prefixing all my messages with a tag and then filtering by that tag to keep things relevant. So my messages look like this with no filter:

TAG: {
"key1": "value1",
"key2": "value2",
... 
}

When I filter by TAG, I only see the first line because as far as I can tell, Xcode is just checking line by line instead checking by message.

TAG: {

How can I make Xcode output all the lines in the JSON? Is there a better way than writing my own print function that splits by \n and prefixes each line with TAG? This might not even work because the values might have a \n internally.

like image 266
fizzybear Avatar asked May 24 '26 11:05

fizzybear


1 Answers

You can use .description property while printing. Here is an example print(yourObject.description) It prints everything in one line and while doing a filter, you will be able to see everything.

This worked for me. Hope this helps you.

like image 74
Santosh Avatar answered May 27 '26 04:05

Santosh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!