Site Tools

How to: Dump Debug Information to a Log File

Developer: C++
Summary: Discusses using the ON_TextLog class for debugging plug-ins

The openNURBS SDK, which is also included with the Rhino SDK, contains an ON_TextLog class that makes it very simple to write, or dump, information to a text file. The class can be handy when debugging geometric objects, for most objects have the ability to dump their contents to a log file.

The following is an example of using the ON_TextLog class to dump the contents of a B-rep object to a text file. For more information on ON_TextLog, see opennurbs_textlog.h.


CRhinoCommand::result CCommandTest::RunCommand( 
    const CRhinoCommandContext& context )
  CRhinoGetObject go;
  go.SetCommandPrompt( L"Select brep" );
       CRhinoGetObject::surface_object |
       CRhinoGetObject::polysrf_object );
  go.GetObjects( 1, 1 );
  if( go.CommandResult() == CRhinoCommand::success )
    const ON_Brep* brep = go.Object(0).Brep();
    if( brep )
      FILE* fp = ON::OpenFile( L"c:\\bug_report.txt", L"w" );
      if( fp )
        ON_TextLog text_log( fp );
        text_log.Print( L"Dumping Brep...\n" );
        brep->Dump( text_log );
        ON::CloseFile( fp );
  return CRhinoCommand::success;
developer/sdksamples/textlog.txt ยท Last modified: 2020/08/14 (external edit)