Fix to trace function to include return values when patterns are used

The pattern was being applied to every trace event. In cases of return
values, we want to just print them.