Itoyori  v0.0.1
logger.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ityr/common/util.hpp"
5 
6 namespace ityr::common {
7 
9 
10 template <int Level = 1>
11 inline void verbose(const char* fmt, ...) {
12  if constexpr (Level <= max_verbose_level) {
13  constexpr int slen = 256;
14  static char msg[slen];
15 
16  va_list args;
17  va_start(args, fmt);
18  vsnprintf(msg, slen, fmt, args);
19  va_end(args);
20 
21  fprintf(stderr, "%ld: %s\n", clock_gettime_ns(), msg);
22  }
23 }
24 
25 }
#define ITYR_MAX_VERBOSE_LEVEL
Definition: allocator.hpp:16
va_list args
Definition: util.hpp:76
fprintf(stderr, "\x1b[31m%s\x1b[39m\n", msg)
vsnprintf(msg, slen, fmt, args)
constexpr int max_verbose_level
Definition: logger.hpp:8
uint64_t clock_gettime_ns()
Definition: util.hpp:65
va_start(args, fmt)
void verbose(const char *fmt,...)
Definition: logger.hpp:11