Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define log_error(...) log_api(__FILE__, __LINE__, log_api_severity::error, /*print_console=*/false, __VA_ARGS__)
- template<typename ...Args>
- std::result_of<Args...>::type tmpl_call_return_f(Args...&& args)
- {
- return log_api(__FILE__, __LINE__, log_api_severity::error, /*print_console=*/false, std::forward<Args>(args)...);
- }
- #include <iostream>
- #include <cstdarg>
- // This is the macro I want to convert into constexpr variadic template?
- #define log_error(...) log_api(__FILE__, __LINE__, log_api_severity::error, /*print_console=*/false, __VA_ARGS__)
- // Error: use the 'typename' keyword to treat nontype "std::result_of<_Fty>::type[with _Fty=Args...]" as a type in a dependent context
- // template<typename ...Args>
- // std::result_of<Args...>::type tmpl_call_return_f(Args...&& args)
- // {
- // return log_api(__FILE__, __LINE__, log_api_severity::error, /*print_console=*/false, std::forward<Args>(args)...);
- // }
- // Log severity levels
- enum class log_api_severity
- {
- error = 0,
- warning = 50,
- info = 51,
- debug = 52,
- trace = 53,
- all = 54,
- disabled = 55,
- };
- bool log_api(const char* filename, const int line_number, const log_api_severity severity, const bool print_console, const char* fmt, ...)
- {
- char msg[1024] = "";
- va_list args;
- va_start(args, fmt);
- vsprintf_s(msg, sizeof(msg), fmt, args);
- // write in the log file...
- printf("%s", msg);
- va_end(args);
- return true;
- }
- int main()
- {
- log_error("this is an error message");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement