From cd65d6de69d71f79a4e13cf7dced3ca204d08670 Mon Sep 17 00:00:00 2001 From: Ponnuvel Palaniyappan Date: Sun, 31 Mar 2019 22:05:37 +0100 Subject: [PATCH 1/4] namespace qualify stat functions --- include/spdlog/details/os.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 646805e6..8e8476f0 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -196,7 +196,7 @@ inline bool file_exists(const filename_t &filename) SPDLOG_NOEXCEPT return (attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY)); #else // common linux/unix all have the stat system call struct stat buffer; - return (stat(filename.c_str(), &buffer) == 0); + return (::stat(filename.c_str(), &buffer) == 0); #endif } @@ -229,14 +229,14 @@ inline size_t filesize(FILE *f) // 64 bits(but not in osx or cygwin, where fstat64 is deprecated) #if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__) struct stat64 st; - if (fstat64(fd, &st) == 0) + if (::fstat64(fd, &st) == 0) { return static_cast(st.st_size); } #else // unix 32 bits or cygwin struct stat st; - if (fstat(fd, &st) == 0) + if (::fstat(fd, &st) == 0) { return static_cast(st.st_size); } From d366a06461e216884215dbb440e90a049b0596ce Mon Sep 17 00:00:00 2001 From: Daniel Binsmaier Date: Thu, 4 Apr 2019 09:25:21 +0200 Subject: [PATCH 2/4] Fix unexpected log macro expansion --- include/spdlog/spdlog.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 79a75196..74f01a06 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -327,8 +327,10 @@ inline void critical(const wchar_t *fmt, const Args &... args) // #define SPDLOG_LOGGER_CALL(logger, level, ...) \ - if (logger->should_log(level)) \ - logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) + do { \ + if (logger->should_log(level)) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) \ + } while (0) #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE #define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__) From 631416d54a139ddd28d90feff4f494340802eb52 Mon Sep 17 00:00:00 2001 From: Daniel Binsmaier Date: Thu, 4 Apr 2019 12:04:53 +0200 Subject: [PATCH 3/4] Fix missing ';' in log macros --- include/spdlog/spdlog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 74f01a06..87a7c184 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -329,7 +329,7 @@ inline void critical(const wchar_t *fmt, const Args &... args) #define SPDLOG_LOGGER_CALL(logger, level, ...) \ do { \ if (logger->should_log(level)) \ - logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \ } while (0) #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE From ad63efdaf772582631eca20783aaa8c2badd7766 Mon Sep 17 00:00:00 2001 From: Martin Krammer <43210132+martinkrammer@users.noreply.github.com> Date: Sat, 6 Apr 2019 11:17:11 +0200 Subject: [PATCH 4/4] Update README.md In order to use basic_logger_mt an additional include is required. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e51f2721..7b3d39d7 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ async... Elapsed: 0.349851 2,858,358/sec #### Basic usage ```c++ #include "spdlog/spdlog.h" +#include "spdlog/sinks/basic_file_sink.h" + int main() { spdlog::info("Welcome to spdlog!");