14#include <fmt/format.h>
19#include <unordered_map>
33 Logger(std::string name,
unsigned debug_level);
47 template <
typename... Args>
48 void info(
const char* fmt, Args&&... args)
53 fmt::styled(
"INFO ", fmt::fg(fmt::color::cornflower_blue)),
55 fmt::vformat(fmt, fmt::make_format_args(args...)));
64 template <
typename... Args>
65 void debug(
const char* fmt, Args&&... args)
70 fmt::styled(
"DEBUG", fmt::fg(fmt::color::pale_violet_red)),
72 fmt::vformat(fmt, fmt::make_format_args(args...)));
77 m_trace_starts[trace_name] = std::chrono::high_resolution_clock::now();
86 const auto time = std::chrono::high_resolution_clock::now();
87 const std::chrono::duration<double, std::milli> ms_double = time -
m_trace_starts[trace_name];
88 trace(
"{} took {:.3f}ms", trace_name, ms_double.count());
97 template <
typename... Args>
98 void trace(
const char* fmt, Args&&... args)
103 fmt::styled(
"TRACE", fmt::fg(fmt::color::golden_rod)),
105 fmt::vformat(fmt, fmt::make_format_args(args...)));
112 std::unordered_map<std::string, std::chrono::time_point<std::chrono::high_resolution_clock>>
m_trace_starts;
std::unordered_map< std::string, std::chrono::time_point< std::chrono::high_resolution_clock > > m_trace_starts
void info(const char *fmt, Args &&... args)
Write an info level log using fmtlib.
void trace(const char *fmt, Args &&... args)
Write a trace level log using fmtlib.
Logger(std::string name, unsigned debug_level)
Construct a new Logger object.
void debug(const char *fmt, Args &&... args)
Write a debug level log using fmtlib.
std::vector< std::string > m_active_traces
void traceStart(std::string &&trace_name)
unsigned debugLevel() const