Hi, if you develop production with HealthShare, you may have noticed there is a nice tracing feature available - HS.Util.Trace.Operations. This feature allows visually tracing debug information, in structured way. It complements good old logging macros like $$$LOGINFO, $$$TRACE and alike. I use this feature a lot. However, it has limited functionality, it works nice with classes that extend XML Adapter, streams or data types, but it doesn't work well with arbitrary objects that do no extend from XML Adapter. I decided to implement a subclass of the trace helper class HS.Util.Trace.Helper and add the missing functionality.  here is the code I added:
            Elseif tVal.%Extends("%Stream.Object") {<br>                    Do tStream.Write("")
                    Set tSC = tStream.CopyFrom(tVal)
                    Do tStream.Write("")<br>                    Do tVal.Rewind()<br>                }<br>                <strong>else {<br>                    // DK - arbitrary object<br>                    set tInitIO=$io<br>                    set %Stream=##class(%Stream.TmpCharacter).%New()<br>                    use tInitIO::("^"_$zname)<br>                    do ##class(%Device).ReDirectIO(1)           <br>                    zw tVal<br>                    If ##class(%Device).ReDirectIO(0) Use tInitIO<br>                    do %Stream.Rewind()<br>                    Do tStream.Write("")
                    set tSC=tStream.CopyFrom(%Stream)
                    Do tStream.Write("")                   <br>                }</strong>

               
I have used a nice feature of redirecting output to variable, - added following class method to my trace helper class.
ClassMethod redirects() [ Private, ProcedureBlock = 0 ]<br>{<br>#; Public entry points for redirection<br>wstr(s) Do %Stream.Write(s) Quit<br>wchr(a) Do %Stream.Write($char(a)) Quit<br>wnl Do %Stream.Write($char(13,10)) Quit<br>wff Do %Stream.Write($char(13,10,13,10)) Quit<br>wtab(n) New chars Set $piece(chars," ",n+1)="" Do %Stream.Write(chars) Quit<br>rstr(len,time) Quit ""<br>rchr(time) Quit ""<br>}
you can see the sample output in the following picture. ![](/sites/default/files/inline/images/images/annotation_2020-05-15_112250.jpg) All you need in you business component, is to add your trace helper subclass to the list of base classes and call do ..HSTrace() method or its macro equivalent $$$HSTRACE with your desired parameters. Hope you find this little improvement useful.   Dan