diff options
-rw-r--r-- | include/jau/debug.hpp | 9 | ||||
-rw-r--r-- | src/debug.cpp | 10 |
2 files changed, 18 insertions, 1 deletions
diff --git a/include/jau/debug.hpp b/include/jau/debug.hpp index 84ab123..4626023 100644 --- a/include/jau/debug.hpp +++ b/include/jau/debug.hpp @@ -129,6 +129,15 @@ namespace jau { void PLAIN_PRINT(const bool printPrefix, const char * format, ...) noexcept; /** + * Convenient fprintf() invocation, prepending the given elapsed_ms timestamp. + * @param elapsed_ms the given elapsed time in milliseconds + * @param stream the output stream + * @param format the format + * @param args the optional arguments + */ + int fprintf_td(const uint64_t elapsed_ms, FILE* stream, const char * format, ...) noexcept; + + /** * Convenient fprintf() invocation, prepending the environment::getElapsedMillisecond() timestamp. * @param stream the output stream * @param format the format diff --git a/src/debug.cpp b/src/debug.cpp index 4236e6d..2c6069a 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -267,8 +267,16 @@ void jau::PLAIN_PRINT(const bool printPrefix, const char * format, ...) noexcept fflush(stderr); } +int jau::fprintf_td(const uint64_t elapsed_ms, FILE* stream, const char * format, ...) noexcept { + int res = ::fprintf(stream, "[%s] ", jau::to_decstring(elapsed_ms, ',', 9).c_str()); + va_list args; + va_start (args, format); + res += ::vfprintf(stream, format, args); // NOLINT(clang-analyzer-valist.Uninitialized): clang-tidy bug + va_end (args); + return res; +} int jau::fprintf_td(FILE* stream, const char * format, ...) noexcept { - int res = ::fprintf(stderr, "[%s] ", jau::to_decstring(environment::getElapsedMillisecond(), ',', 9).c_str()); + int res = ::fprintf(stream, "[%s] ", jau::to_decstring(environment::getElapsedMillisecond(), ',', 9).c_str()); va_list args; va_start (args, format); res += ::vfprintf(stream, format, args); // NOLINT(clang-analyzer-valist.Uninitialized): clang-tidy bug |