Skip to content
Snippets Groups Projects
debug.cpp 1.38 KiB
Newer Older
Thomas Moulard's avatar
Thomas Moulard committed
/*
 * Copyright 2010,
 * François Bleibel,
 * Olivier Stasse,
Thomas Moulard's avatar
Thomas Moulard committed
 * CNRS/AIST
Thomas Moulard's avatar
Thomas Moulard committed
 */
#include <fstream>
#include <ios>

using namespace dynamicgraph;

#ifdef WIN32
const char *DebugTrace::DEBUG_FILENAME_DEFAULT =
    "c:/tmp/dynamic-graph-traces.txt";
Bergé's avatar
Bergé committed
#else  /*WIN32*/
const char *DebugTrace::DEBUG_FILENAME_DEFAULT =
    "/tmp/dynamic-graph-traces.txt";
Bergé's avatar
Bergé committed
#endif /*WIN32*/
Bergé's avatar
Bergé committed
#ifdef WIN32
std::ofstream dg_debugfile("C:/tmp/dynamic-graph-traces.txt",
                           std::ios::trunc &std::ios::out);
Bergé's avatar
Bergé committed
#else  /*WIN32*/
std::ofstream dg_debugfile("/tmp/dynamic-graph-traces.txt",
                           std::ios::trunc &std::ios::out);
Bergé's avatar
Bergé committed
#endif /*WIN32*/
std::ofstream dg_debugfile;
Bergé's avatar
Bergé committed
class dgDebug_init {
 public:
  dgDebug_init() { dg_debugfile.setstate(std::ios::failbit); }
Bergé's avatar
Bergé committed
};
dgDebug_init dgDebug_initialisator;
Bergé's avatar
Bergé committed
DebugTrace dgDEBUGFLOW(dg_debugfile);
DebugTrace dgERRORFLOW(dg_debugfile);
}  // namespace dynamicgraph
Bergé's avatar
Bergé committed

void DebugTrace::openFile(const char *filename) {
  if (dg_debugfile.good() && dg_debugfile.is_open()) dg_debugfile.close();
Bergé's avatar
Bergé committed
  dg_debugfile.clear();
  dg_debugfile.open(filename, std::ios::trunc & std::ios::out);
Bergé's avatar
Bergé committed
void DebugTrace::closeFile(const char *) {
  if (dg_debugfile.good() && dg_debugfile.is_open()) {
    dg_debugfile.close();
  }
  dg_debugfile.setstate(std::ios::failbit);