diff --git a/support/ppPrint.h b/support/ppPrint.h index 265a443f..d1aabc2f 100644 --- a/support/ppPrint.h +++ b/support/ppPrint.h @@ -14,12 +14,25 @@ namespace pumipic { #define ACTIVE_GPU_EXECUTION #endif + inline FILE* pp_stdout = stdout; + inline FILE* pp_stderr = stderr; + + inline void pp_set_stdout(FILE* out) { + assert(out != NULL); + pp_stdout = out; + } + + inline void pp_set_stderr(FILE* err) { + assert(err != NULL); + pp_stderr = err; + } + template void pPrintError(const char* fmt, const Args&... args) { #if defined(SPDLOG_ENABLED) && defined(PP_PRINT_ENABLED) spdlog::error("{}", fmt::sprintf(fmt, args...)); #elif defined(PP_PRINT_ENABLED) - fprintf(stderr, fmt, args...); + fprintf(pp_stderr, fmt, args...); #endif } @@ -28,8 +41,8 @@ namespace pumipic { void pPrintInfo(const char* fmt, const Args&... args) { #if defined(SPDLOG_ENABLED) && defined(PP_PRINT_ENABLED) && !defined(ACTIVE_GPU_EXECUTION) spdlog::info("{}", fmt::sprintf(fmt, args...)); - #elif defined(PP_PRINT_ENABLED) - Kokkos::printf(fmt, args...); + #elif defined(PP_PRINT_ENABLED) && !defined(ACTIVE_GPU_EXECUTION) + fprintf(pp_stdout, fmt, args...); #endif }