16 #include <deal.II/base/job_identifier.h> 17 #include <deal.II/base/logstream.h> 18 #include <deal.II/base/thread_management.h> 27 DEAL_II_NAMESPACE_OPEN
69 "An exception occurred in LogStream::Prefix::~Prefix."));
109 if ((
this == &deallog) &&
file)
110 *
std_out << (
"You still have content that was written to 'deallog' " 111 "but not flushed to the screen or a file while the " 112 "program is being terminated. This would lead to a " 113 "segmentation fault. Make sure you flush the " 114 "content of the 'deallog' object using 'std::endl' " 115 "before the end of the program.")
150 class QueryStreambuf :
public std::streambuf
157 , newline_written_(
false)
167 return newline_written_;
172 overflow(int_type ch)
override 174 newline_written_ =
true;
184 bool newline_written_;
189 std::ostream inject(&query_streambuf);
193 if (query_streambuf.flushed())
195 std::lock_guard<std::mutex> lock(write_lock);
201 at_newline = query_streambuf.newline_written();
207 *
file << stream.str() << std::flush;
219 const bool print_job_id,
220 const std::ios_base::fmtflags flags)
222 std::lock_guard<std::mutex> lock(log_lock);
233 std::lock_guard<std::mutex> lock(log_lock);
260 outstreams.
get()->setf(std::ios::showpoint | std::ios::left);
273 ExcMessage(
"You can't ask for the std::ostream object for the output " 274 "file if none had been set before."));
283 return (
file !=
nullptr);
291 static std::string empty_string;
309 pre += std::string(
":");
351 std::lock_guard<std::mutex> lock(log_lock);
362 std::lock_guard<std::mutex> lock(log_lock);
373 std::lock_guard<std::mutex> lock(log_lock);
381 std::stack<std::string> &
384 #ifdef DEAL_II_WITH_THREADS 386 std::stack<std::string> &local_prefixes =
prefixes.
get(exists);
392 const tbb::enumerable_thread_specific<std::stack<std::string>> &impl =
397 const tbb::enumerable_thread_specific<
398 std::stack<std::string>>::const_iterator first_elem = impl.begin();
400 if (first_elem != impl.end())
402 local_prefixes = *first_elem;
406 return local_prefixes;
419 const std::thread::id thread = std::this_thread::get_id();
424 *
std_out <<
'[' << thread <<
']';
433 *
file <<
'[' << thread <<
']';
436 *
file << head <<
':';
440 DEAL_II_NAMESPACE_CLOSE
#define AssertNothrow(cond, exc)
std::streamsize precision(const std::streamsize prec)
Threads::ThreadLocalStorage< std::stack< std::string > > prefixes
const std::string & get_prefix() const
void attach(std::ostream &o, const bool print_job_id=true, const std::ios_base::fmtflags flags=std::ios::showpoint|std::ios::left)
unsigned int depth_file(const unsigned int n)
std::streamsize width(const std::streamsize wide)
bool log_thread_id(const bool flag)
std::ostream & get_file_stream()
std::ios::fmtflags flags(const std::ios::fmtflags f)
static const JobIdentifier & get_dealjobid()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define Assert(cond, exc)
tbb::enumerable_thread_specific< T > & get_implementation()
std::stack< std::string > & get_prefixes() const
unsigned int depth_console(const unsigned int n)
SmartPointer< LogStream, LogStream::Prefix > stream
Prefix(const std::string &text)
std::ostream & get_console()
Threads::ThreadLocalStorage< std::shared_ptr< std::ostringstream > > outstreams
void push(const std::string &text)
LogStream & operator<<(std::ostream &(*p)(std::ostream &))
std::ostringstream & get_stream()