[MOAB-dev] r3846 - MOAB/trunk/src

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed May 5 13:33:53 CDT 2010


Author: kraftche
Date: 2010-05-05 13:33:53 -0500 (Wed, 05 May 2010)
New Revision: 3846

Added:
   MOAB/trunk/src/DebugOutput.cpp
   MOAB/trunk/src/DebugOutput.hpp
Modified:
   MOAB/trunk/src/Makefile.am
Log:
Add utility class for debug output.  

Implements the usual features:
o Optionally prefix all lines w/ user-sepcified string
o Optionally prefix all lines w/ MPI rank
o Filtering based on verbosity level
o Runtime enable/disable
o Utility method to print moab::Range 


Added: MOAB/trunk/src/DebugOutput.cpp
===================================================================
--- MOAB/trunk/src/DebugOutput.cpp	                        (rev 0)
+++ MOAB/trunk/src/DebugOutput.cpp	2010-05-05 18:33:53 UTC (rev 3846)
@@ -0,0 +1,236 @@
+#include "DebugOutput.hpp"
+#include "moab/Range.hpp"
+#include "moab/CN.hpp"
+#include "Internals.hpp"
+#include <iostream>
+#include <string.h>
+#include <algorithm>
+
+#ifdef USE_MPI
+#  include "moab_mpi.h"
+#endif
+
+namespace moab {
+
+DebugOutputStream::~DebugOutputStream() {}
+
+class FILEDebugStream : public DebugOutputStream
+{
+private:
+  FILE* filePtr;
+public:
+  FILEDebugStream( FILE* filep ) : filePtr(filep) {}
+  void println( int rank, const char* pfx, const char* str );
+  void println( const char* pfx, const char* str );
+};
+void FILEDebugStream::println( int rank, const char* pfx, const char* str )
+  { fprintf(filePtr, "%3d  %s%s\n", rank, pfx, str); fflush(filePtr); }
+void FILEDebugStream::println( const char* pfx, const char* str )
+  { 
+    fputs( pfx, filePtr ); 
+    fputs( str, filePtr ); 
+    fputc( '\n', filePtr ); 
+    fflush(filePtr); 
+  }
+
+
+class CxxDebugStream : public DebugOutputStream
+{
+private:
+  std::ostream& outStr;
+public:
+  CxxDebugStream( std::ostream& str ) : outStr(str) {}
+  void println( int rank, const char* pfx, const char* str );
+  void println( const char* pfx, const char* str );
+};
+void CxxDebugStream::println( int rank, const char* pfx, const char* str )


More information about the moab-dev mailing list