19#include <system_error>
36inline std::string
hex_prefix(
const std::vector<uint8_t>& data,
38 std::ostringstream oss;
39 oss << std::hex << std::setfill(
'0');
40 const size_t limit = std::min(max_len, data.size());
41 for (
size_t i = 0; i < limit; ++i) {
42 oss << std::setw(2) << static_cast<unsigned int>(data[i]);
56 if (tag ==
"warn" || tag ==
"warning") {
69 return static_cast<int>(sev) <=
static_cast<int>(current);
72inline void ch_log_impl(
const char* level,
const std::string& msg,
const char* file,
int line,
74 std::string lvl(level ? level :
"");
76 std::cerr <<
"[ChapterForge][" << level <<
"][" << file <<
":" << line <<
" " << func
77 <<
"] " << msg << std::endl;
79 std::cerr <<
"[ChapterForge][" << level <<
"] " << msg << std::endl;
83#define CH_LOG(level, message) \
85 if (ch_should_log(level)) { \
86 std::ostringstream _ch_log_ss; \
87 _ch_log_ss << message; \
88 ch_log_impl(level, _ch_log_ss.str(), __FILE__, __LINE__, \
LogVerbosity
Definition logging.hpp:27
void ch_log_impl(const char *level, const std::string &msg, const char *file, int line, const char *func)
Definition logging.hpp:72
bool ch_should_log(const char *level)
Definition logging.hpp:66
constexpr chapterforge::LogVerbosity ch_severity_for_tag(std::string_view tag)
Definition logging.hpp:52
Definition chapterforge.hpp:19
LogVerbosity get_log_verbosity()
Get current logging verbosity.
constexpr size_t kHexPreviewBytes
Definition logging.hpp:35
std::string hex_prefix(const std::vector< uint8_t > &data, size_t max_len=kHexPreviewBytes)
Definition logging.hpp:36
void set_log_verbosity(LogVerbosity level)
Set global logging verbosity.