25 #ifndef DATATOOLS_TRACER_H 26 #define DATATOOLS_TRACER_H 46 tracer(
int id_,
const std::string & filename_,
const std::string & label_ =
"");
72 void initialize(
int id_,
const std::string & filename_);
75 const std::string & filename_,
76 bool preserved_file_);
80 std::ofstream &
out(
bool increment_ =
true);
83 void trace(
const Type & value_,
bool increment_ =
true)
85 out(increment_) <<
' ' << value_;
86 if (increment_)
out(
false) <<
'\n';
90 const std::string & filename_ =
"");
96 std::string _filename_;
97 bool _preserved_file_;
98 std::unique_ptr<std::ofstream> _fout_;
105 #define DT_TRACER_INIT(TracerId,TracerFilename) \ 107 ::datatools::tracer::grab_global_tracer(TracerId,TracerFilename); \ 111 #define DT_TRACER_TRACE(TracerId,Value) \ 113 ::datatools::tracer & t = ::datatools::tracer::grab_global_tracer(TracerId); \ 114 if (! t.is_initialized()) t.initialize(TracerId); \ 119 #define DT_TRACER_MESSAGE(TracerId,Message) \ 121 ::datatools::tracer & t = ::datatools::tracer::grab_global_tracer(TracerId); \ 122 if (! t.is_initialized()) t.initialize(TracerId); \ 123 t.out(true) << ' ' << Message << std::endl ; \ 127 #define DT_TRACER_RESET(TracerId) \ 129 ::datatools::tracer::grab_global_tracer(TracerId).reset(); \ 133 #endif // DATATOOLS_TRACER_H