Created
January 4, 2024 02:35
-
-
Save vtta/5756c8b838b0e63235606568abf8b515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LOG_HPP | |
#define LOG_HPP | |
#include <print> | |
#include <source_location> | |
template <class... Args> | |
struct info { | |
info(std::format_string<Args...> fmt, Args &&...args, | |
std::source_location const &loc = std::source_location::current()) { | |
std::print(stderr, "[{}:{}]{}: ", loc.file_name(), loc.line(), | |
loc.function_name()); | |
std::println(stderr, fmt, std::forward<Args>(args)...); | |
} | |
}; | |
template <class... Args> | |
info(std::format_string<Args...> fmt, Args &&...args) -> info<Args...>; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment