simplify code by appling varargs messages and warnings

This commit is contained in:
Axel Kohlmeyer
2021-05-05 18:19:12 -04:00
parent 8fd0595f1b
commit 22e93468d6
48 changed files with 162 additions and 181 deletions

View File

@ -258,6 +258,20 @@ void Error::warning(const std::string &file, int line, const std::string &str)
if (logfile) fputs(mesg.c_str(),logfile);
}
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_warning(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
warning(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
warning(file,line,e.what());
}
}
/* ----------------------------------------------------------------------
called by one proc in world, typically proc 0
write message to screen and logfile (if logflag is set)
@ -271,6 +285,20 @@ void Error::message(const std::string &file, int line, const std::string &str)
if (logfile) fputs(mesg.c_str(),logfile);
}
/* ----------------------------------------------------------------------
forward vararg version to single string version
------------------------------------------------------------------------- */
void Error::_message(const std::string &file, int line, fmt::string_view format,
fmt::format_args args)
{
try {
message(file,line,fmt::vformat(format, args));
} catch (fmt::format_error &e) {
message(file,line,e.what());
}
}
/* ----------------------------------------------------------------------
shutdown LAMMPS
called by all procs in one world