16 #include <deal.II/base/logstream.h> 17 #include <deal.II/base/job_identifier.h> 18 #include <deal.II/base/memory_consumption.h> 19 #include <deal.II/base/thread_management.h> 21 #ifdef DEAL_II_HAVE_SYS_RESOURCE_H 22 # include <sys/resource.h> 25 #ifdef DEAL_II_HAVE_UNISTD_H 35 DEAL_II_NAMESPACE_OPEN
60 print_thread_id(false),
66 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) 94 if ((
this == &deallog) &&
file)
95 std::cerr << (
"You still have content that was written to 'deallog' " 96 "but not flushed to the screen or a file while the " 97 "program is being terminated. This would lead to a " 98 "segmentation fault. Make sure you flush the " 99 "content of the 'deallog' object using 'std::endl' " 100 "before the end of the program.")
114 const double double_threshold_,
115 const float float_threshold_,
116 const double offset_)
161 class QueryStreambuf :
public std::streambuf
167 : flushed_(
false), newline_written_(
false)
174 bool newline_written()
176 return newline_written_;
179 int_type overflow(int_type ch)
181 newline_written_ =
true;
190 bool newline_written_;
195 std::ostream inject (&query_streambuf);
199 if (query_streambuf.flushed())
207 at_newline = query_streambuf.newline_written();
213 *
file << stream.str() << std::flush;
225 const bool print_job_id)
229 o.setf(std::ios::showpoint | std::ios::left);
268 ExcMessage(
"You can't ask for the std::ostream object for the output " 269 "file if none had been set before."));
284 static std::string empty_string;
301 pre += std::string(
":");
399 std::stack<std::string> &
402 #ifdef DEAL_II_WITH_THREADS 404 std::stack<std::string> &local_prefixes =
prefixes.
get(exists);
410 const tbb::enumerable_thread_specific<std::stack<std::string> > &impl
415 const tbb::enumerable_thread_specific<std::stack<std::string> >::const_iterator first_elem
418 if (first_elem != impl.end())
420 local_prefixes = *first_elem;
424 return local_prefixes;
435 #ifdef DEAL_II_HAVE_SYS_RESOURCE_H 440 getrusage(RUSAGE_SELF, &usage);
441 utime = usage.ru_utime.tv_sec + 1.e-6 * usage.ru_utime.tv_usec;
466 *
std_out <<
'[' << thread <<
']';
476 int p =
file->width(6);
477 *
file << utime <<
':';
481 *
file <<
'[' << thread <<
']';
484 *
file << head <<
':';
492 struct tms current_tms;
493 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_TIMES) 494 const clock_t tick = sysconf(_SC_CLK_TCK);
495 const double time = 1./tick * times(¤t_tms);
497 const double time = 0.;
498 const unsigned int tick = 100;
499 current_tms.tms_utime = 0;
500 current_tms.tms_stime = 0;
501 current_tms.tms_cutime = 0;
502 current_tms.tms_cstime = 0;
505 <<
" User: " << 1./tick * (current_tms.tms_utime -
reference_tms.tms_utime)
506 <<
" System: " << 1./tick * (current_tms.tms_stime -
reference_tms.tms_stime)
507 <<
" Child-User: " << 1./tick * (current_tms.tms_cutime -
reference_tms.tms_cutime)
508 <<
" Child-System: " << 1./tick * (current_tms.tms_cstime -
reference_tms.tms_cstime)
519 std::size_t mem =
sizeof(*this);
534 DEAL_II_NAMESPACE_CLOSE
std::streamsize precision(const std::streamsize prec)
unsigned int this_thread_id()
Threads::ThreadLocalStorage< std::stack< std::string > > prefixes
const std::string & get_prefix() const
void threshold_double(const double t)
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::streambuf * old_cerr
std::ios::fmtflags flags(const std::ios::fmtflags f)
LogStream & operator<<(const double t)
static ::ExceptionBase & ExcMessage(std::string arg1)
void test_mode(const bool on=true, const double double_threshold=1.e-10, const float float_threshold=1.e-7f, const double offset=1.e-7)
#define Assert(cond, exc)
tbb::enumerable_thread_specific< T > & get_implementation()
std::stack< std::string > & get_prefixes() const
void threshold_float(const float t)
bool log_time_differences(const bool flag)
unsigned int depth_console(const unsigned int n)
void attach(std::ostream &o, const bool print_job_id=true)
std::ostream & get_console()
double reference_time_val
bool log_execution_time(const bool flag)
void push(const std::string &text)
static ::ExceptionBase & ExcNotImplemented()
std::ostringstream & get_stream()
std::size_t memory_consumption() const