diff --git a/include/cantera/base/global.h b/include/cantera/base/global.h index 98d2935db..8a6bf834c 100644 --- a/include/cantera/base/global.h +++ b/include/cantera/base/global.h @@ -20,6 +20,7 @@ #define CT_GLOBAL_H #include "ct_defs.h" +#include "cantera/ext/format.h" namespace Cantera { @@ -164,7 +165,10 @@ inline void writelog(const std::string& msg, int loglevel) * @param fmt c format string for the following arguments * @ingroup textlogs */ -void writelogf(const char* fmt,...); +template +void writelogf(const char* fmt, const Args& ... args) { + writelog(fmt::sprintf(fmt, args...)); +} //! Write an end of line character to the screen and flush output void writelogendl(); diff --git a/src/base/global.cpp b/src/base/global.cpp index 6df7aad3f..39328e8f0 100644 --- a/src/base/global.cpp +++ b/src/base/global.cpp @@ -5,9 +5,6 @@ #include "application.h" #include "units.h" -#include -#include - using namespace std; namespace Cantera @@ -35,24 +32,6 @@ void writelog(const std::string& msg) app()->writelog(msg); } -void writelogf(const char* fmt,...) -{ - enum { BUFSIZE = 2048 }; - char sbuf[BUFSIZE]; - - va_list args; - va_start(args, fmt); - -#ifdef _MSC_VER - _vsnprintf(sbuf, BUFSIZE, fmt, args); -#else - vsprintf(sbuf, fmt, args); -#endif - - writelog(sbuf); - va_end(args); -} - void writelogendl() { app()->writelogendl();