//---------------------------------------------------------------------------// // 1100101 |_ mov #0, r4 __ // // 11 |_ <0xb380 %5c4> / _|_ _____ ___ // // 0110 |_ 3.50 -> 3.60 | _\ \ / _ (_-< // // |_ base# + offset |_| /_\_\___/__/ // //---------------------------------------------------------------------------// // fxos/util/log: Basic logging utilities // // This header exposes a single macro // FxOS_log(LEVEL, FORMAT, ...) // where LEVEL should be "LOG", "WRN" or "ERR", FORMAT is a printf()-style // format and variable arguments are provided as needed. // // The log level can be set with log_getminlevel() and log_setminlevel(). The // point of this header is to report runtime warnings and errors caused by // invalid input or flawed internal logic, and print performance metrics in // debug mode. // // The log level can also be set with the FXOS_LOG environment variable. //--- #ifndef FXOS_UTIL_LOG_H #define FXOS_UTIL_LOG_H #include namespace FxOS { /* Message levels, for masking */ constexpr int LOG_LEVEL_LOG = 0; constexpr int LOG_LEVEL_WRN = 1; constexpr int LOG_LEVEL_ERR = 2; /* Select the log level */ void log_setminlevel(int level); /* Get the minimum log level */ int log_getminlevel(); /* General message logger */ void logmsg(int level, char const *file, int line, char const *func, std::string message); } /* namespace FxOS */ #define FxOS_log(level, fmt, ...) \ FxOS::logmsg(FxOS::LOG_LEVEL_##level, __FILE__, __LINE__, __func__, \ format(fmt, ##__VA_ARGS__)) #endif /* FXOS_UTIL_LOG_H */