]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
provide a simple function call to open and attach logfile
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Oct 2011 18:43:50 +0000 (18:43 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Oct 2011 18:43:50 +0000 (18:43 +0000)
git-svn-id: https://svn.dealii.org/trunk@24683 0785d39b-7218-0410-832d-ea1e28bc413d

tests/tests.h

index e9c961b03e7810a11f8ba453eb5ff2600cfa9128..90e34769f010145baff3f3a0f6b3603e2f745172 100644 (file)
 // so in each and every testcase
 using namespace dealii;
 
+// Function for initialize deallog. Normally, it should be called at
+// the beginning of main() like
+//
+// initlog(__FILE__);
+//
+// This will open the correct output file, divert log output there and
+// switch off screen output. If screen output is desired, provide the
+// optional second argument as 'true'.
+std::string deallogname;
+std::ofstream deallogfile;
+
+inline
+void
+initlog(const char* filename, bool console=false)
+{
+  deallogname = JobIdentifier::base_name(filename) + std::string("/output");
+  deallogfile.open(deallogname.c_str());
+  deallog.attach(deallogfile);
+  if (!console)
+    deallog.depth_console(0);
+}
+
 
 // overload floating point output operators for LogStream so that small
 // numbers below a certain threshold are simply printed as zeros. this removes

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.