]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Allow to pop the "DEAL" prefix from logstream
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Jun 2013 08:36:26 +0000 (08:36 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 11 Jun 2013 08:36:26 +0000 (08:36 +0000)
git-svn-id: https://svn.dealii.org/trunk@29805 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/source/base/logstream.cc

index dfb20d925cf11b88d5255b6af40920bac7a4b569..70ebb99fe16c74dea231974bfb36ce5a9c5a0140 100644 (file)
@@ -374,7 +374,7 @@ parallel benchmark timings.
 <li> Improved and Fixed: LogStream (and deallog) now respect std::flush in
 addition to std::endl to write out content to the console/file.
 Furthermore, LogStream::push(...) and LogStream::pop() now work in a thread
-safe manner.
+safe manner. Also allow to pop() the prefix "DEAL".
 <br>
 (Matthias Maier, 2013/04/18)
 </li>
index e0fc350cf5194ff218d7147bffbe5b94701524de..b9197a1b1e33e2025d0f0e48da8411ad19a39797 100644 (file)
@@ -226,14 +226,22 @@ LogStream::has_file() const
 const std::string &
 LogStream::get_prefix() const
 {
-  return get_prefixes().top();
+  static std::string empty_string;
+
+  if (get_prefixes().size() > 0)
+    return get_prefixes().top();
+  else
+    return empty_string;
 }
 
 
 void
 LogStream::push (const std::string &text)
 {
-  std::string pre=get_prefixes().top();
+  std::string pre;
+  if (get_prefixes().size() > 0)
+    pre = get_prefixes().top();
+
   pre += text;
   pre += std::string(":");
   get_prefixes().push(pre);
@@ -242,7 +250,7 @@ LogStream::push (const std::string &text)
 
 void LogStream::pop ()
 {
-  if (get_prefixes().size() > 1)
+  if (get_prefixes().size() > 0)
     get_prefixes().pop();
 }
 
@@ -436,7 +444,8 @@ LogStream::print_line_head()
       if (print_thread_id)
         *std_out << '[' << thread << ']';
 
-      *std_out <<  head << ':';
+      if (head.size() > 0)
+        *std_out <<  head << ':';
     }
 
   if (file && (get_prefixes().size() <= file_depth))
@@ -453,7 +462,8 @@ LogStream::print_line_head()
       if (print_thread_id)
         *file << '[' << thread << ']';
 
-      *file << head << ':';
+      if (head.size() > 0)
+        *file << head << ':';
     }
 }
 

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.