]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
prepare for time log
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Jan 2000 04:35:48 +0000 (04:35 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Jan 2000 04:35:48 +0000 (04:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@2185 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/logstream.h
deal.II/base/source/log.cc

index 14cc58019f579728ecb158e923869c086da0a70f..c9d04b6c5d9a07cb86c427ac75c48bc34f4a944a 100644 (file)
@@ -93,7 +93,11 @@ class LogStream
                                      * prefixes for output to a file.
                                      */
     unsigned int file_depth;
-    
+
+                                     /**
+                                     * Flag for printing execution time.
+                                     */
+    bool print_utime;
   public:
                                     /**
                                      * Standard constructor, since we
@@ -157,6 +161,14 @@ class LogStream
                                      */
     void depth_file (unsigned int n);
 
+                                     /**
+                                     * Set time printing flag. If this flag
+                                     * is true, each output line will
+                                     * be prepended by the user time used
+                                     * by the running program so far.
+                                     */
+  void log_execution_time(bool flag);
+
                                     /**
                                      * Output a constant something through
                                      * this stream.
@@ -187,6 +199,13 @@ class LogStream
                                      * Declare this function as a friend.
                                      */
     friend void endl (LogStream &);
+private:
+                                     /**
+                                     * Print head of line. This prints
+                                     * optional time information and
+                                     * the contents of the prefix stack.
+                                     */
+  void print_line_head();
 };
 
 
@@ -209,7 +228,12 @@ LogStream::push (const string& text)
   prefixes.push(pre);
 }
 
-
+inline
+void
+LogStream::log_execution_time(bool flag)
+{
+  print_utime = flag;
+}
 
 // sorry for the weird following declaration spanning 5 lines, but
 // doc++ gets confused if we be more compact :-(
@@ -225,12 +249,7 @@ operator<< (const T& t)
                                   // and a colon
   if (was_endl)
     {
-      if (prefixes.size() <= std_depth)
-       *std_out << prefixes.top() << ':';
-
-      if (file && (prefixes.size() <= file_depth))
-       *file << prefixes.top() << ':';
-
+      print_line_head();
       was_endl = false;
     };
 
index 02d70e7213513c6d9c87761a4135004575f0c874..a19c11dc231f9db194fae07c191b9c4af838d6cd 100644 (file)
@@ -3,7 +3,7 @@
 #include <base/logstream.h>
 #include <base/job_identifier.h>
 
-
+#include <sys/rusage.h>
 
 LogStream deallog;
 
@@ -11,7 +11,8 @@ LogStream deallog;
 
 LogStream::LogStream()
                : std_out(&cerr), file(0), was_endl(true),
-                 std_depth(10000), file_depth(10000)
+                 std_depth(10000), file_depth(10000),
+                 print_utime(false)
 {
   prefixes.push("DEAL:");
 }
@@ -31,29 +32,42 @@ LogStream::attach(ostream& o)
 void LogStream::detach ()
 {
   file = 0;
-};
+}
 
 
 
-void LogStream::pop ()
+void
+LogStream::pop ()
 {
   prefixes.pop();
-};
+}
 
 
 
-void LogStream::depth_console(unsigned n)
+void
+LogStream::depth_console(unsigned n)
 {
   std_depth = n;
-};
+}
 
 
 
-void LogStream::depth_file(unsigned n)
+void
+LogStream::depth_file(unsigned n)
 {
   file_depth = n;
-};
+}
+
+
+void
+LogStream::print_line_head()
+{
+  if (prefixes.size() <= std_depth)
+    *std_out << prefixes.top() << ':';
 
+  if (file && (prefixes.size() <= file_depth))
+    *file << prefixes.top() << ':';
+}
 
 
 LogStream&

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.