diff options
author | Sven Göthel <[email protected]> | 2024-05-11 04:24:56 +0200 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-05-11 04:24:56 +0200 |
commit | a300f90f0c255c0b7c78466b57cf144195c4d016 (patch) | |
tree | 1e2a73771511004822a74c37e566b4478d2190d4 | |
parent | 53ec39486355fa607eb6484f2bbc2fb8e0b9b08e (diff) |
debug: Fix fprintf_td(): Use stream arg for elapsed_md portion (not stderr); Add fprintf_td() variant with given elapsed_ms argument
-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 |