Skip to content

Instantly share code, notes, and snippets.

@vtta
Created January 4, 2024 02:35
Show Gist options
  • Save vtta/5756c8b838b0e63235606568abf8b515 to your computer and use it in GitHub Desktop.
Save vtta/5756c8b838b0e63235606568abf8b515 to your computer and use it in GitHub Desktop.
#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