13#include <fmt/format.h>
18#include <unordered_map>
32 Logger(std::string name,
unsigned debug_level);
46 template <
typename... Args>
47 void info(
const char* fmt, Args&&... args)
52 fmt::styled(
"INFO ", fmt::fg(fmt::color::cornflower_blue)),
54 fmt::vformat(fmt, fmt::make_format_args(args...)));
63 template <
typename... Args>
64 void debug(
const char* fmt, Args&&... args)
69 fmt::styled(
"DEBUG", fmt::fg(fmt::color::pale_violet_red)),
71 fmt::vformat(fmt, fmt::make_format_args(args...)));
76 m_trace_starts[trace_name] = std::chrono::high_resolution_clock::now();
85 const auto time = std::chrono::high_resolution_clock::now();
86 const std::chrono::duration<double, std::milli> ms_double = time -
m_trace_starts[trace_name];
87 trace(
"{} took {:.3f}ms", trace_name, ms_double.count());
96 template <
typename... Args>
97 void trace(
const char* fmt, Args&&... args)
102 fmt::styled(
"TRACE", fmt::fg(fmt::color::golden_rod)),
104 fmt::vformat(fmt, fmt::make_format_args(args...)));
111 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