Skip to content
Discussion options

You must be logged in to vote

The macro allows string literals to be concatenated.
However, it is not an easy way to figure out.

https://godbolt.org/z/v7GP4oMMj

#include <string>
#include "spdlog/spdlog.h"


int fetch_var() {
    return 1;
}

namespace logger {

template <typename... Args>
inline void debug(spdlog::format_string_t<Args...> fmt, Args &&...args) {
    int variable3 = fetch_var();
    spdlog::debug(fmt, std::forward<Args>(args)..., variable3);
};

}

#define LOG_DEBUG(FORMAT, ...) logger::debug((FORMAT " {}"), __VA_ARGS__)


int main() {
    auto variable1 = "12";
    auto variable2 = "3";
    LOG_DEBUG("{}-{}", variable1, variable2);
}

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@CsatiZoltan
Comment options

@tt4g
Comment options

@tt4g
Comment options

Answer selected by CsatiZoltan
@CsatiZoltan
Comment options

@tt4g
Comment options

@tt4g
Comment options

@CsatiZoltan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants