Ejemplo n.º 1
0
IMPBASEEXPORT void pop_log_context() {
  if (context_initializeds >= static_cast<int>(contexts.size()-1)) {
    internal::log_indent-=2;
    std::string message= std::string("end ")
      +get_context_name(contexts.size()-1)+"\n";
    internal::stream.write(message.c_str(), message.size());
    internal::stream.strict_sync();
    -- context_initializeds;
  }
  contexts.pop_back();
}
Ejemplo n.º 2
0
std::string get_context_message() {
  if (contexts.empty()) return std::string();
  std::ostringstream oss;
  oss << "\nContext: ";
  for (unsigned int i=0; i< contexts.size(); ++i) {
    if (i != 0) {
      oss << "/";
    }
    oss << get_context_name(i);
  }
  return oss.str();
}
Ejemplo n.º 3
0
void pop_log_context() {
#ifdef _OPENMP
  if (!omp_in_parallel())
#endif
  {
    if (internal::log_context_initializeds >=
        static_cast<int>(internal::log_contexts.size() - 1)) {
      internal::log_indent -= 2;
      std::string message =
          std::string("end ") +
          get_context_name(internal::log_contexts.size() - 1) + "\n";
      internal::stream.write(message.c_str(), message.size());
      internal::stream.strict_sync();
      --internal::log_context_initializeds;
    }
    internal::log_contexts.pop_back();
  }
}
Ejemplo n.º 4
0
void add_to_log(std::string str) {
  IMP_INTERNAL_CHECK(static_cast<int>(internal::initialized)==11111111,
                     "You connot use the log before main is called.");
  if (!contexts.empty()
      && context_initializeds != static_cast<int>(contexts.size())) {
    for (unsigned int i=0; i< contexts.size(); ++i) {
      if (context_initializeds < static_cast<int>(i)) {
        std::string message= std::string("begin ")
          +get_context_name(i)+":\n";
        internal::stream.write(message.c_str(), message.size());
        internal::stream.strict_sync();
        internal::log_indent+=2;
        context_initializeds=i;
      }
    }
  }
  internal::stream.write(str.c_str(), str.size());
  internal::stream.strict_sync();
}
Ejemplo n.º 5
0
void add_to_log(std::string str) {
#ifdef _OPENMP
#pragma omp critical(imp_log)
#endif
  {
    if (!internal::log_contexts.empty() &&
        internal::log_context_initializeds !=
            static_cast<int>(internal::log_contexts.size())) {
      for (unsigned int i = 0; i < internal::log_contexts.size(); ++i) {
        if (internal::log_context_initializeds < static_cast<int>(i)) {
          std::string message =
              std::string("begin ") + get_context_name(i) + ":\n";
          internal::stream.write(message.c_str(), message.size());
          internal::stream.strict_sync();
          internal::log_indent += 2;
          internal::log_context_initializeds = i;
        }
      }
    }
    internal::stream.write(str.c_str(), str.size());
    internal::stream.strict_sync();
  }
}