Skip to content

Instantly share code, notes, and snippets.

@tekknolagi
Forked from vtta/log.hpp
Created March 22, 2024 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekknolagi/5ec11075242fd61082cbbc0306e83e92 to your computer and use it in GitHub Desktop.
Save tekknolagi/5ec11075242fd61082cbbc0306e83e92 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