<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>
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);
void LogStream::pop ()
{
- if (get_prefixes().size() > 1)
+ if (get_prefixes().size() > 0)
get_prefixes().pop();
}
if (print_thread_id)
*std_out << '[' << thread << ']';
- *std_out << head << ':';
+ if (head.size() > 0)
+ *std_out << head << ':';
}
if (file && (get_prefixes().size() <= file_depth))
if (print_thread_id)
*file << '[' << thread << ']';
- *file << head << ':';
+ if (head.size() > 0)
+ *file << head << ':';
}
}