From 3cf4d340947e87fb0786a4aaea4a791cb419df56 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Mon, 28 Sep 2020 16:55:01 -0500 Subject: [PATCH] let R header defines switch to REprintf over fprintf(stdderr) --- include/spdlog/logger-inl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 69d6a1de..224522d3 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -247,7 +247,11 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg) auto tm_time = details::os::localtime(system_clock::to_time_t(now)); char date_buf[64]; std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); - fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str()); + #if !defined(R_R_H) || !defined(USING_R) + std::fprintf(stderr, "[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str()); + #else + REprintf("[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf, name().c_str(), msg.c_str()); + #endif } } } // namespace spdlog