Skip to content

Commit

Permalink
invalid format strings are now correctly being reported in compile-ti…
Browse files Browse the repository at this point in the history
…me. Fixes #13
  • Loading branch information
odygrd committed Apr 17, 2020
1 parent dca589a commit a3f9280
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

## v1.2.0
* Linking and including an external version of `fmt` is now supported. See TweakMe.h
* Fix compiler warnings when using clang's -Wdocumentation. Fixes [#12](https://github.com/odygrd/quill/issues/12).
* Fixed compiler warnings when using clang's -Wdocumentation. Fixes [#12](https://github.com/odygrd/quill/issues/12).
* Fixed a bug that wouldn't report a compile-time error for invalid format strings. Fixes [#13](https://github.com/odygrd/quill/issues/13).

## v1.1.0
* Daily file handler. The file handler rollover every 24 hours
* Rotating file handler. The file handler will rollover based on the size of the file
Expand Down
17 changes: 13 additions & 4 deletions quill/quill/include/quill/detail/LogMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include "quill/detail/misc/Common.h"

#include "quill/Logger.h"
#include "quill/Fmt.h"
#include "quill/Logger.h"
#include "quill/detail/misc/Macros.h"

// Config Options
Expand All @@ -22,12 +22,21 @@
#define QUILL_LOG_LEVEL_CRITICAL 7
#define QUILL_LOG_LEVEL_NONE 8

/**
* Check in compile time the correctness of a format string
*/
template <typename S, typename... Args, typename Char = fmt::char_t<S>>
constexpr void check_format(const S& format_str, Args&&...)
{
fmt::internal::check_format_string<std::remove_reference_t<Args>...>(format_str);
}

// Main Log Macros
// clang-format off
#define QUILL_LOGGER_CALL(logger, log_statement_level, fmt, ...) do { \
FMT_STRING(fmt); \
#define QUILL_LOGGER_CALL(logger, log_statement_level, fmt, ...) do { \
check_format(FMT_STRING(fmt), ##__VA_ARGS__); \
static constexpr quill::detail::StaticLogRecordInfo log_line_info{QUILL_STRINGIFY(__LINE__), __FILE__, __FUNCTION__, fmt, log_statement_level}; \
logger->log<log_statement_level>(&log_line_info, ##__VA_ARGS__); \
logger->log<log_statement_level>(&log_line_info, ##__VA_ARGS__); \
} while (0)
// clang-format on

Expand Down

0 comments on commit a3f9280

Please sign in to comment.