]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Time logging is possible
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Jan 2000 00:38:57 +0000 (00:38 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Jan 2000 00:38:57 +0000 (00:38 +0000)
git-svn-id: https://svn.dealii.org/trunk@2222 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/log.cc

index 3e450ca373eb3feed7ea2cc0db6fa75709494f18..05bc76f9f18d086e07630a90e50e889d2b35a24e 100644 (file)
@@ -3,7 +3,8 @@
 #include <base/logstream.h>
 #include <base/job_identifier.h>
 
-//#include <sys/rusage.h>
+#include <sys/resource.h>
+#include <iomanip>
 
 LogStream deallog;
 
@@ -15,6 +16,7 @@ LogStream::LogStream()
                  print_utime(false)
 {
   prefixes.push("DEAL:");
+  std_out->setf(ios::showpoint | ios::left);
 }
 
 
@@ -24,6 +26,7 @@ void
 LogStream::attach(ostream& o)
 {
   file = &o;
+  o.setf(ios::showpoint | ios::left);
   o << dealjobid();
 }
 
@@ -62,11 +65,31 @@ LogStream::depth_file(unsigned n)
 void
 LogStream::print_line_head()
 {
+  rusage usage;
+  float utime = 0.;
+  if (print_utime)
+    {
+      getrusage(RUSAGE_SELF, &usage);
+      utime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
+    }
+  
   if (prefixes.size() <= std_depth)
+    {
+      if (print_utime)
+       {
+         *std_out << utime << ':';
+       }
     *std_out << prefixes.top() << ':';
-
+    }
+  
   if (file && (prefixes.size() <= file_depth))
+    {
+      if (print_utime)
+       {
+         *file << utime << ':';
+       }  
     *file << prefixes.top() << ':';
+    }
 }
 
 

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.