Skip to content

Commit

Permalink
Update an example
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Sep 21, 2022
1 parent a48e335 commit 3272a7a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,20 @@ binary footprint, for example (https://godbolt.org/z/oba4Mc):

.. code:: c++

#include <fmt/format.h>
#include <fmt/core.h>

void vlog(const char* file, int line, fmt::string_view format,
fmt::format_args args) {
fmt::print("{}: {}: ", file, line);
fmt::vprint(format, args);
}

template <typename S, typename... Args>
void log(const char* file, int line, const S& format, Args&&... args) {
template <typename... T>
void log(const char* file, int line, fmt::format_string<T...> format, T&&... args) {
vlog(file, line, format, fmt::make_format_args(args...));
}

#define MY_LOG(format, ...) \
log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define MY_LOG(format, ...) log(__FILE__, __LINE__, format, __VA_ARGS__)

MY_LOG("invalid squishiness: {}", 42);

Expand Down

0 comments on commit 3272a7a

Please sign in to comment.