File saycomplete.h
File List > code_source > templat > include > TempLat > util > log > saycomplete.h
Go to the documentation of this file
#ifndef TEMPLAT_UTIL_LOG_SAYCOMPLETE_H
#define TEMPLAT_UTIL_LOG_SAYCOMPLETE_H
/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
Released under the MIT license, see LICENSE.md. */
// File info: Main contributor(s): Wessel Valkenburg, Year: 2019
#include <string>
#include "TempLat/util/log/streamcacher.h"
#include "TempLat/util/log/colors.h"
#include "TempLat/util/log/timespent.h"
#include "TempLat/util/log/strippathfromfilename.h"
#include "TempLat/util/tdd/tddmacros.h"
namespace TempLat
{
inline StreamCacher SayComplete(const char *fname, int line)
{
StreamCacher result;
long long int ms = TimeSpent::getProcessAge();
auto ss = ms / 1000;
ms = ms % 1000;
char msBuf[6];
snprintf(msBuf, 6, "%03lli", ms);
result << KBLU "(" << ss << "." << msBuf << "s) ";
if (fname != NULL) result << fname << ":" << line << " -->";
result << "\n" KRESET;
return result;
}
#define say TempLat::SayComplete(TempLat::StripPathFromFileName(__FILE__), __LINE__)
#define sayShort TempLat::SayComplete(NULL, 0)
#define sayMPI \
TempLat::SayComplete((std::string("MPI Rank ") + std::to_string(TempLat::MPICommReference::worldRank()) + " - " + \
std::string(TempLat::StripPathFromFileName(__FILE__))) \
.c_str(), \
__LINE__)
} // namespace TempLat
#endif